bare-addon-resolve
Advanced tools
Comparing version 1.0.0 to 1.0.1
44
index.js
@@ -59,5 +59,9 @@ const errors = require('./lib/errors') | ||
if (startsWithWindowsDriveLetter(specifier)) { | ||
specifier = '/' + specifier | ||
} | ||
let directoryURL | ||
if (specifier[specifier.length - 1] === '/') { | ||
if (specifier[specifier.length - 1] === '/' || specifier[specifier.length - 1] === '\\') { | ||
directoryURL = new URL(specifier, parentURL) | ||
@@ -120,2 +124,4 @@ } else { | ||
scopeURL.pathname = scopeURL.pathname.substring(0, scopeURL.pathname.lastIndexOf('/')) | ||
if (scopeURL.pathname.length === 3 && isWindowsDriveLetter(scopeURL.pathname.substring(1))) break | ||
} while (scopeURL.pathname !== '/') | ||
@@ -125,4 +131,2 @@ } | ||
exports.file = function * (filename, parentURL, opts = {}) { | ||
if (filename === '.' || filename === '..' || filename[filename.length - 1] === '/') return false | ||
if (parentURL.protocol === 'file:' && /%2f|%5c/i.test(filename)) { | ||
@@ -140,1 +144,35 @@ throw errors.INVALID_ADDON_SPECIFIER(`Addon specifier '${filename}' is invalid`) | ||
} | ||
// https://infra.spec.whatwg.org/#ascii-upper-alpha | ||
function isASCIIUpperAlpha (c) { | ||
return c >= 0x41 && c <= 0x5a | ||
} | ||
// https://infra.spec.whatwg.org/#ascii-lower-alpha | ||
function isASCIILowerAlpha (c) { | ||
return c >= 0x61 && c <= 0x7a | ||
} | ||
// https://infra.spec.whatwg.org/#ascii-alpha | ||
function isASCIIAlpha (c) { | ||
return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c) | ||
} | ||
// https://url.spec.whatwg.org/#windows-drive-letter | ||
function isWindowsDriveLetter (input) { | ||
return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && ( | ||
input.charCodeAt(1) === 0x3a || | ||
input.charCodeAt(1) === 0x7c | ||
) | ||
} | ||
// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter | ||
function startsWithWindowsDriveLetter (input) { | ||
return input.length >= 2 && isWindowsDriveLetter(input) && ( | ||
input.length === 2 || | ||
input.charCodeAt(2) === 0x2f || | ||
input.charCodeAt(2) === 0x5c || | ||
input.charCodeAt(2) === 0x3f || | ||
input.charCodeAt(2) === 0x23 | ||
) | ||
} |
{ | ||
"name": "bare-addon-resolve", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Low-level addon resolution algorithm for Bare", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
20358
149