extensionless
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "extensionless", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -27,9 +27,11 @@ import {access, existsSync, readFileSync} from 'fs' | ||
let extToSkip = ['.wasm', '.cjs', '.mjs', '.js', '.json'] | ||
let indexFiles = resolveDirs ? lookFor.map(e => `index.${e}`) : [] | ||
let postfixes = lookFor.map(e => `.${e}`).concat(indexFiles.map(p => `${sep}${p}`)) | ||
let findPostfix = async (specifier, context) => { | ||
let isAbsolutePath = isAbsolute(specifier) | ||
for (let postfix of specifier.endsWith(sep) ? indexFiles : postfixes) { | ||
let path = isAbsolutePath | ||
? specifier + postfix | ||
let findPostfix = async (specifier, context, isAbs) => { | ||
let postfixCandidates = specifier.endsWith(sep) ? indexFiles | ||
: extToSkip.includes(extname(spec)) ? [] : postfixes | ||
for (let postfix of postfixCandidates) { | ||
let path = isAbs ? specifier + postfix | ||
: join(dirname(fileURLToPath(context.parentURL)), specifier + postfix) | ||
@@ -43,13 +45,11 @@ | ||
let extToSkip = ['.wasm', '.cjs', '.mjs', '.js', '.json'] | ||
let relPrefixes = [...new Set(['./', '../', `.${sep}`, `..${sep}`])] | ||
export async function resolve(specifier, context, nextResolve) { | ||
let spec = specifier.startsWith('file://') ? fileURLToPath(specifier) : specifier | ||
let isAbs = isAbsolute(spec) | ||
let postfix = (isAbsolute(spec) || relPrefixes.some(p => spec.startsWith(p))) | ||
&& (spec = normalize(spec)) | ||
&& (spec.endsWith(sep) || !extToSkip.includes(extname(spec))) | ||
&& await findPostfix(spec, context) | ||
let postfix = (isAbs || relPrefixes.some(p => spec.startsWith(p))) | ||
&& await findPostfix(normalize(spec), context, isAbs) || '' | ||
return await nextResolve(specifier + (postfix || '')) | ||
return await nextResolve(specifier + postfix) | ||
} |
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
4151
42