@jsenv/module-resolution
Advanced tools
Comparing version 4.0.0 to 5.0.0
@@ -47,2 +47,19 @@ 'use strict'; | ||
var hrefToOrigin = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme(href); | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
}; | ||
var hrefToPathname = function hrefToPathname(href) { | ||
@@ -74,17 +91,19 @@ return ressourceToPathname(hrefToRessource(href)); | ||
var hrefToOrigin = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme(href); | ||
var pathnameToDirname = function pathnameToDirname(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex === -1) return ""; | ||
return pathname.slice(0, slashLastIndex); | ||
}; | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
var pathnameToExtension = function pathnameToExtension(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
if (slashLastIndex !== -1) { | ||
pathname = pathname.slice(slashLastIndex + 1); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
var dotLastIndex = pathname.lastIndexOf("."); | ||
if (dotLastIndex === -1) return ""; // if (dotLastIndex === pathname.length - 1) return "" | ||
return pathname.slice(dotLastIndex); | ||
}; | ||
@@ -253,8 +272,2 @@ | ||
var hrefToScheme$1 = function hrefToScheme(href) { | ||
var colonIndex = href.indexOf(":"); | ||
if (colonIndex === -1) return ""; | ||
return href.slice(0, colonIndex); | ||
}; | ||
var isSchemeRelativeSpecifier = function isSchemeRelativeSpecifier(specifier) { | ||
@@ -266,22 +279,5 @@ return specifier.slice(0, 2) === "//"; | ||
specifier = _ref.specifier; | ||
return "".concat(hrefToScheme$1(importer), ":").concat(specifier); | ||
return "".concat(hrefToScheme(importer), ":").concat(specifier); | ||
}; | ||
var hrefToOrigin$1 = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme$1(href); | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
}; | ||
var isOriginRelativeSpecifier = function isOriginRelativeSpecifier(specifier) { | ||
@@ -297,38 +293,6 @@ var firstChar = specifier[0]; | ||
specifier = _ref.specifier; | ||
var importerOrigin = hrefToOrigin$1(importer); | ||
var importerOrigin = hrefToOrigin(importer); | ||
return "".concat(importerOrigin, "/").concat(specifier.slice(1)); | ||
}; | ||
var hrefToPathname$1 = function hrefToPathname(href) { | ||
return ressourceToPathname$1(hrefToRessource$1(href)); | ||
}; | ||
var hrefToRessource$1 = function hrefToRessource(href) { | ||
var scheme = hrefToScheme$1(href); | ||
if (scheme === "file") { | ||
return href.slice("file://".length); | ||
} | ||
if (scheme === "https" || scheme === "http") { | ||
// remove origin | ||
var afterProtocol = href.slice(scheme.length + "://".length); | ||
var pathnameSlashIndex = afterProtocol.indexOf("/", "://".length); | ||
return afterProtocol.slice(pathnameSlashIndex); | ||
} | ||
return href.slice(scheme.length + 1); | ||
}; | ||
var ressourceToPathname$1 = function ressourceToPathname(ressource) { | ||
var searchSeparatorIndex = ressource.indexOf("?"); | ||
return searchSeparatorIndex === -1 ? ressource : ressource.slice(0, searchSeparatorIndex); | ||
}; | ||
var pathnameToDirname = function pathnameToDirname(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex === -1) return ""; | ||
return pathname.slice(0, slashLastIndex); | ||
}; | ||
// "../folder/file.js" | ||
@@ -344,3 +308,3 @@ | ||
specifier = _ref.specifier; | ||
var importerPathname = hrefToPathname$1(importer); // ./foo.js on /folder/file.js -> /folder/foo.js | ||
var importerPathname = hrefToPathname(importer); // ./foo.js on /folder/file.js -> /folder/foo.js | ||
// ./foo/bar.js on /folder/file.js -> /folder/foo/bar.js | ||
@@ -350,3 +314,3 @@ // ./foo.js on /folder/subfolder/file.js -> /folder/subfolder/foo.js | ||
if (specifier.startsWith("./")) { | ||
var _importerOrigin = hrefToOrigin$1(importer); | ||
var _importerOrigin = hrefToOrigin(importer); | ||
@@ -375,3 +339,3 @@ var importerDirname = pathnameToDirname(importerPathname); | ||
var importerOrigin = hrefToOrigin$1(importer); | ||
var importerOrigin = hrefToOrigin(importer); | ||
var resolvedPathname = "".concat(importerFolders.join("/"), "/").concat(unresolvedPathname); | ||
@@ -384,3 +348,3 @@ return "".concat(importerOrigin).concat(resolvedPathname); | ||
specifier = _ref.specifier; | ||
var importerOrigin = hrefToOrigin$1(importer); | ||
var importerOrigin = hrefToOrigin(importer); | ||
return "".concat(importerOrigin, "/").concat(specifier); | ||
@@ -431,15 +395,2 @@ }; | ||
var pathnameToExtension = function pathnameToExtension(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex !== -1) { | ||
pathname = pathname.slice(slashLastIndex + 1); | ||
} | ||
var dotLastIndex = pathname.lastIndexOf("."); | ||
if (dotLastIndex === -1) return ""; // if (dotLastIndex === pathname.length - 1) return "" | ||
return pathname.slice(dotLastIndex); | ||
}; | ||
var resolvePath = function resolvePath(_ref) { | ||
@@ -474,3 +425,3 @@ var specifier = _ref.specifier, | ||
if (importer) { | ||
var importerPathname = hrefToPathname$1(importer); | ||
var importerPathname = hrefToPathname(importer); | ||
var importerExtension = pathnameToExtension(importerPathname); | ||
@@ -485,9 +436,4 @@ return "".concat(remappedImport).concat(importerExtension); | ||
exports.hrefToOrigin = hrefToOrigin$1; | ||
exports.hrefToPathname = hrefToPathname$1; | ||
exports.hrefToScheme = hrefToScheme$1; | ||
exports.pathnameToDirname = pathnameToDirname; | ||
exports.pathnameToExtension = pathnameToExtension; | ||
exports.resolveImport = resolveImport; | ||
exports.resolvePath = resolvePath; | ||
//# sourceMappingURL=main.js.map |
@@ -46,2 +46,19 @@ var __dmail_assert__ = function (exports) { | ||
var hrefToOrigin = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme(href); | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
}; | ||
var hrefToPathname = function hrefToPathname(href) { | ||
@@ -73,17 +90,19 @@ return ressourceToPathname(hrefToRessource(href)); | ||
var hrefToOrigin = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme(href); | ||
var pathnameToDirname = function pathnameToDirname(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex === -1) return ""; | ||
return pathname.slice(0, slashLastIndex); | ||
}; | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
var pathnameToExtension = function pathnameToExtension(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
if (slashLastIndex !== -1) { | ||
pathname = pathname.slice(slashLastIndex + 1); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
var dotLastIndex = pathname.lastIndexOf("."); | ||
if (dotLastIndex === -1) return ""; // if (dotLastIndex === pathname.length - 1) return "" | ||
return pathname.slice(dotLastIndex); | ||
}; | ||
@@ -252,8 +271,2 @@ | ||
var hrefToScheme$1 = function hrefToScheme(href) { | ||
var colonIndex = href.indexOf(":"); | ||
if (colonIndex === -1) return ""; | ||
return href.slice(0, colonIndex); | ||
}; | ||
var isSchemeRelativeSpecifier = function isSchemeRelativeSpecifier(specifier) { | ||
@@ -266,22 +279,5 @@ return specifier.slice(0, 2) === "//"; | ||
specifier = _ref.specifier; | ||
return "".concat(hrefToScheme$1(importer), ":").concat(specifier); | ||
return "".concat(hrefToScheme(importer), ":").concat(specifier); | ||
}; | ||
var hrefToOrigin$1 = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme$1(href); | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
}; | ||
var isOriginRelativeSpecifier = function isOriginRelativeSpecifier(specifier) { | ||
@@ -298,36 +294,4 @@ var firstChar = specifier[0]; | ||
specifier = _ref.specifier; | ||
var importerOrigin = hrefToOrigin$1(importer); | ||
var importerOrigin = hrefToOrigin(importer); | ||
return "".concat(importerOrigin, "/").concat(specifier.slice(1)); | ||
}; | ||
var hrefToPathname$1 = function hrefToPathname(href) { | ||
return ressourceToPathname$1(hrefToRessource$1(href)); | ||
}; | ||
var hrefToRessource$1 = function hrefToRessource(href) { | ||
var scheme = hrefToScheme$1(href); | ||
if (scheme === "file") { | ||
return href.slice("file://".length); | ||
} | ||
if (scheme === "https" || scheme === "http") { | ||
// remove origin | ||
var afterProtocol = href.slice(scheme.length + "://".length); | ||
var pathnameSlashIndex = afterProtocol.indexOf("/", "://".length); | ||
return afterProtocol.slice(pathnameSlashIndex); | ||
} | ||
return href.slice(scheme.length + 1); | ||
}; | ||
var ressourceToPathname$1 = function ressourceToPathname(ressource) { | ||
var searchSeparatorIndex = ressource.indexOf("?"); | ||
return searchSeparatorIndex === -1 ? ressource : ressource.slice(0, searchSeparatorIndex); | ||
}; | ||
var pathnameToDirname = function pathnameToDirname(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex === -1) return ""; | ||
return pathname.slice(0, slashLastIndex); | ||
}; // "../folder/file.js" | ||
@@ -345,3 +309,3 @@ | ||
specifier = _ref.specifier; | ||
var importerPathname = hrefToPathname$1(importer); // ./foo.js on /folder/file.js -> /folder/foo.js | ||
var importerPathname = hrefToPathname(importer); // ./foo.js on /folder/file.js -> /folder/foo.js | ||
// ./foo/bar.js on /folder/file.js -> /folder/foo/bar.js | ||
@@ -351,3 +315,3 @@ // ./foo.js on /folder/subfolder/file.js -> /folder/subfolder/foo.js | ||
if (specifier.startsWith("./")) { | ||
var _importerOrigin = hrefToOrigin$1(importer); | ||
var _importerOrigin = hrefToOrigin(importer); | ||
@@ -376,3 +340,3 @@ var importerDirname = pathnameToDirname(importerPathname); | ||
var importerOrigin = hrefToOrigin$1(importer); | ||
var importerOrigin = hrefToOrigin(importer); | ||
var resolvedPathname = "".concat(importerFolders.join("/"), "/").concat(unresolvedPathname); | ||
@@ -385,3 +349,3 @@ return "".concat(importerOrigin).concat(resolvedPathname); | ||
specifier = _ref.specifier; | ||
var importerOrigin = hrefToOrigin$1(importer); | ||
var importerOrigin = hrefToOrigin(importer); | ||
return "".concat(importerOrigin, "/").concat(specifier); | ||
@@ -432,15 +396,2 @@ }; | ||
var pathnameToExtension = function pathnameToExtension(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex !== -1) { | ||
pathname = pathname.slice(slashLastIndex + 1); | ||
} | ||
var dotLastIndex = pathname.lastIndexOf("."); | ||
if (dotLastIndex === -1) return ""; // if (dotLastIndex === pathname.length - 1) return "" | ||
return pathname.slice(dotLastIndex); | ||
}; | ||
var resolvePath = function resolvePath(_ref) { | ||
@@ -475,3 +426,3 @@ var specifier = _ref.specifier, | ||
if (importer) { | ||
var importerPathname = hrefToPathname$1(importer); | ||
var importerPathname = hrefToPathname(importer); | ||
var importerExtension = pathnameToExtension(importerPathname); | ||
@@ -486,7 +437,2 @@ return "".concat(remappedImport).concat(importerExtension); | ||
exports.hrefToOrigin = hrefToOrigin$1; | ||
exports.hrefToPathname = hrefToPathname$1; | ||
exports.hrefToScheme = hrefToScheme$1; | ||
exports.pathnameToDirname = pathnameToDirname; | ||
exports.pathnameToExtension = pathnameToExtension; | ||
exports.resolveImport = resolveImport; | ||
@@ -493,0 +439,0 @@ exports.resolvePath = resolvePath; |
@@ -7,6 +7,1 @@ // documented export | ||
export { resolveImport } from "./src/resolvePath/resolveImport.js" | ||
export { hrefToOrigin } from "./src/resolvePath/hrefToOrigin.js" | ||
export { hrefToPathname } from "./src/resolvePath/hrefToPathname.js" | ||
export { hrefToScheme } from "./src/resolvePath/hrefToScheme.js" | ||
export { pathnameToDirname } from "./src/resolvePath/pathnameToDirname.js" | ||
export { pathnameToExtension } from "./src/resolvePath/pathnameToExtension.js" |
{ | ||
"name": "@jsenv/module-resolution", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"license": "MIT", | ||
@@ -41,3 +41,4 @@ "repository": { | ||
"dependencies": { | ||
"@jsenv/import-map": "1.0.0" | ||
"@jsenv/href": "1.0.0", | ||
"@jsenv/import-map": "1.1.0" | ||
}, | ||
@@ -52,3 +53,3 @@ "devDependencies": { | ||
"@jsenv/node-launcher": "3.5.0", | ||
"@jsenv/node-module-import-map": "6.0.0", | ||
"@jsenv/node-module-import-map": "6.2.0", | ||
"@jsenv/eslint-config": "10.0.0", | ||
@@ -55,0 +56,0 @@ "@jsenv/prettier-config": "1.0.0", |
@@ -0,5 +1,4 @@ | ||
import { hrefToPathname, pathnameToExtension } from "@jsenv/href" | ||
import { applyImportMap } from "@jsenv/import-map" | ||
import { resolveImport } from "./resolveImport.js" | ||
import { hrefToPathname } from "./hrefToPathname.js" | ||
import { pathnameToExtension } from "./pathnameToExtension.js" | ||
@@ -6,0 +5,0 @@ export const resolvePath = ({ specifier, importer, importMap, defaultExtension = true }) => { |
@@ -1,2 +0,2 @@ | ||
import { hrefToOrigin } from "../hrefToOrigin.js" | ||
import { hrefToOrigin } from "@jsenv/href" | ||
import { isAbsoluteSpecifier } from "./absoluteSpecifier.js" | ||
@@ -3,0 +3,0 @@ import { isSchemeRelativeSpecifier } from "./schemeRelativeSpecifier.js" |
@@ -1,2 +0,2 @@ | ||
import { hrefToOrigin } from "../hrefToOrigin.js" | ||
import { hrefToOrigin } from "@jsenv/href" | ||
@@ -3,0 +3,0 @@ // "/folder/file.js" |
// https://github.com/systemjs/systemjs/blob/master/src/common.js | ||
import { hrefToPathname } from "../hrefToPathname.js" | ||
import { hrefToOrigin } from "../hrefToOrigin.js" | ||
import { pathnameToDirname } from "../pathnameToDirname.js" | ||
import { hrefToPathname, hrefToOrigin, pathnameToDirname } from "@jsenv/href" | ||
@@ -6,0 +4,0 @@ // "./folder/file.js" |
@@ -1,2 +0,2 @@ | ||
import { hrefToScheme } from "../hrefToScheme.js" | ||
import { hrefToScheme } from "@jsenv/href" | ||
@@ -3,0 +3,0 @@ // "//folder/file.js" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
180667
2
17
935
+ Added@jsenv/href@1.0.0
+ Added@jsenv/href@1.0.0(transitive)
+ Added@jsenv/import-map@1.1.0(transitive)
- Removed@jsenv/import-map@1.0.0(transitive)
- Removed@jsenv/module-resolution@3.6.0(transitive)
Updated@jsenv/import-map@1.1.0