Socket
Socket
Sign inDemoInstall

@astropub/assert

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

44

lib/vite-plugin.js

@@ -25,3 +25,7 @@ import acornImportAssertionsPlugin from './acorn-plugin.js'

resolveId(sourceId, importerId, options) {
return this.resolve(sourceId, importerId, { skipSelf: true, ...options }).then(
if (!sourceId || !sourceId.includes('assert=')) return
const [ resolveId, assert ] = withModuleAssertions(sourceId)
return this.resolve(resolveId, importerId, { skipSelf: true, ...options }).then(
resolution => {

@@ -31,19 +35,7 @@ // skip null resolutions

const [ resolveId, search ] = resolution.id.split(/(?<=^[^?]+)\?/)
const params = new URLSearchParams(search)
if (params.has('assert')) {
const assertionJSON = params.get('assert')
setModuleAssertions(sourceId, resolution.id, assert)
/** @type {AssertionData} */
const assertionData = JSON.parse(assertionJSON)
params.delete('assert')
const searchParams = [ ...params ].length ? `?${params}` : ''
resolution.id = sourceId
setModuleAssertions(resolution.id, resolveId + searchParams, assertionData)
return resolution
}
return resolution
}

@@ -83,2 +75,22 @@ )

const withModuleAssertions = (
/** @type {string} */ id
) => {
const [ resolveId, search ] = id.split(/(?<=^[^?]+)\?/)
const params = new URLSearchParams(search)
if (!params.has('assert')) return [ resolveId, null ]
const assertionJSON = params.get('assert')
/** @type {AssertionData} */
const assertionData = JSON.parse(assertionJSON)
params.delete('assert')
const searchParams = [ ...params ].length ? `?${params}` : ''
return [ resolveId + searchParams, assertionData ]
}
/** @type {AssertionMap} */

@@ -85,0 +97,0 @@ const moduleAssertions = Object.create(null)

{
"name": "@astropub/assert",
"type": "module",
"version": "0.1.0",
"version": "0.1.1",
"exports": {

@@ -24,3 +24,8 @@ ".": "./index.js",

"vite"
]
],
"license": "CC0-1.0",
"repository": "astro-community/assert",
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
"bugs": "https://github.com/astro-community/assert/issues",
"homepage": "https://github.com/astro-community/assert#readme"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc