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

extensionless

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extensionless - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

2

package.json
{
"name": "extensionless",
"version": "1.3.2",
"version": "1.3.3",
"type": "module",

@@ -5,0 +5,0 @@ "main": "src/index.js",

import {access, existsSync, readFileSync} from 'fs'
import {dirname, extname, isAbsolute, join, posix, win32} from 'path'
import {dirname, extname, isAbsolute, join} from 'path'
import {argv, cwd} from 'process'

@@ -23,29 +23,27 @@

let indexFiles = [lookFor.map(e => `index.${e}`), ['index.json']]
let relatives = indexFiles.map(i => i.map(f => `/${f}`))
let candidates = relatives.map(r => r.map(p => extname(p)).concat(r))
let indexFiles = [lookFor.map(e => `index.${e}`), ['index.json']], empty = [[], []]
let candidates = indexFiles.map(i => i.map(f => extname(f)).concat(i.map(f => `/${f}`)))
let relSpecs = ['.', '..'], separators = [posix.sep, win32.sep]
let relPrefixes = separators.flatMap(s => relSpecs.map(r => r + s))
let extToSkip = ['.js', '.cjs', '.mjs', '.json', '.node', '.wasm'], empty = [[''], ['']]
let relSpecs = ['.', '..'], relPres = ['./', '../', '.\\', '..\\']
let extToSkip = ['.js', '.cjs', '.mjs', '.json', '.node', '.wasm']
export async function resolve(specifier, {importAssertions, parentURL}, nextResolve) {
let isAbs = isAbsolute(specifier), isRelSpec = relSpecs.includes(specifier)
let isRelative = isRelSpec || relPrefixes.some(p => specifier.startsWith(p))
let isAbs = isAbsolute(specifier)
let isRel = relSpecs.includes(specifier) || relPres.some(p => specifier.startsWith(p))
if (specifier.startsWith('file://') || isAbs || isRelative) {
let postfixes = isRelSpec ? relatives
: separators.some(s => specifier.endsWith(s)) ? indexFiles
: extToSkip.includes(extname(specifier)) ? empty : candidates
if (!specifier.startsWith('file://') && !isAbs && !isRel) {
return await nextResolve(specifier)
}
for (let postfix of postfixes[+(importAssertions?.type === 'json')]) {
let fileURL = new URL((isAbs ? 'file://' : '') + specifier + postfix, parentURL)
let selfURL = new URL((isAbs ? 'file://' : '') + specifier, parentURL).href
let postfixes = selfURL.endsWith('/') ? indexFiles
: extToSkip.includes(extname(selfURL)) ? empty : candidates
if (!postfix || await new Promise(r => access(fileURL, e => r(!e)))) {
return await nextResolve(fileURL.href)
}
for (let postfix of postfixes[+(importAssertions?.type === 'json')]) {
if (await new Promise(r => access(new URL(selfURL + postfix), e => r(!e)))) {
return await nextResolve(selfURL + postfix)
}
}
return await nextResolve(specifier)
return await nextResolve(selfURL)
}
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