@jsenv/node-esm-resolution
Advanced tools
Comparing version 0.0.2 to 0.0.4
{ | ||
"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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30083
1133