Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsenv/node-esm-resolution

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/node-esm-resolution - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

2

package.json
{
"name": "@jsenv/node-esm-resolution",
"version": "0.0.2",
"version": "0.0.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -29,3 +29,3 @@ import { lookupPackageScope } from "./lookup_package_scope.js"

if (extension === ".json") {
return "json"
return "url"
}

@@ -43,3 +43,4 @@ if (ambiguousExtensions.includes(extension)) {

}
throw new Error("unsupported file extension")
return "url"
// throw new Error(`unsupported file extension (${extension})`)
}

@@ -46,0 +47,0 @@

@@ -10,2 +10,24 @@ export const asDirectoryUrl = (url) => {

export const getParentUrl = (url) => {
if (url.startsWith("file://")) {
// With node.js new URL('../', 'file:///C:/').href
// returns "file:///C:/" instead of "file:///"
const ressource = url.slice("file://".length)
const slashLastIndex = ressource.lastIndexOf("/")
if (slashLastIndex === -1) {
return url
}
const lastCharIndex = ressource.length - 1
if (slashLastIndex === lastCharIndex) {
const slashBeforeLastIndex = ressource.lastIndexOf(
"/",
slashLastIndex - 1,
)
if (slashBeforeLastIndex === -1) {
return url
}
return `file://${ressource.slice(0, slashBeforeLastIndex + 1)}`
}
return `file://${ressource.slice(0, slashLastIndex + 1)}`
}
return new URL(url.endsWith("/") ? "../" : "./", url).href

@@ -12,0 +34,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc