Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatryk Ludwikowski <psychoxivi@gmail.com>2022-07-28 00:15:05 +0300
committerGitHub <noreply@github.com>2022-07-28 00:15:05 +0300
commit62b95a04337661e3fa17093708b57000054442d9 (patch)
tree04337027c37ab2e6341b921b3ee935e78747c49d /lib
parentde40c31d1fe7521ffbc4e22fd233b18eca149afe (diff)
fix: allow hash character in paths (#5122)
* fix: allow link from path with hash character * fix: allow hash character in path in other places * Remove extra semicolon
Diffstat (limited to 'lib')
-rw-r--r--lib/commands/diff.js14
-rw-r--r--lib/commands/link.js4
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/commands/diff.js b/lib/commands/diff.js
index b8a64bd98..bbd6fae66 100644
--- a/lib/commands/diff.js
+++ b/lib/commands/diff.js
@@ -106,7 +106,7 @@ class Diff extends BaseCommand {
const pkgName = await this.packageName(this.prefix)
return [
`${pkgName}@${this.npm.config.get('tag')}`,
- `file:${this.prefix}`,
+ `file:${this.prefix.replace(/#/g, '%23')}`,
]
}
@@ -134,7 +134,7 @@ class Diff extends BaseCommand {
}
return [
`${pkgName}@${a}`,
- `file:${this.prefix}`,
+ `file:${this.prefix.replace(/#/g, '%23')}`,
]
}
@@ -165,7 +165,7 @@ class Diff extends BaseCommand {
}
return [
`${spec.name}@${spec.fetchSpec}`,
- `file:${this.prefix}`,
+ `file:${this.prefix.replace(/#/g, '%23')}`,
]
}
@@ -178,7 +178,7 @@ class Diff extends BaseCommand {
}
}
- const aSpec = `file:${node.realpath}`
+ const aSpec = `file:${node.realpath.replace(/#/g, '%23')}`
// finds what version of the package to compare against, if a exact
// version or tag was passed than it should use that, otherwise
@@ -211,8 +211,8 @@ class Diff extends BaseCommand {
]
} else if (spec.type === 'directory') {
return [
- `file:${spec.fetchSpec}`,
- `file:${this.prefix}`,
+ `file:${spec.fetchSpec.replace(/#/g, '%23')}`,
+ `file:${this.prefix.replace(/#/g, '%23')}`,
]
} else {
throw this.usageError(`Spec type ${spec.type} not supported.`)
@@ -279,7 +279,7 @@ class Diff extends BaseCommand {
const res = !node || !node.package || !node.package.version
? spec.fetchSpec
- : `file:${node.realpath}`
+ : `file:${node.realpath.replace(/#/g, '%23')}`
return `${spec.name}@${res}`
})
diff --git a/lib/commands/link.js b/lib/commands/link.js
index b0b889ea7..7bce73ed2 100644
--- a/lib/commands/link.js
+++ b/lib/commands/link.js
@@ -122,7 +122,7 @@ class Link extends ArboristWorkspaceCmd {
...this.npm.flatOptions,
prune: false,
path: this.npm.prefix,
- add: names.map(l => `file:${resolve(globalTop, 'node_modules', l)}`),
+ add: names.map(l => `file:${resolve(globalTop, 'node_modules', l).replace(/#/g, '%23')}`),
save,
workspaces: this.workspaceNames,
})
@@ -133,7 +133,7 @@ class Link extends ArboristWorkspaceCmd {
async linkPkg () {
const wsp = this.workspacePaths
const paths = wsp && wsp.length ? wsp : [this.npm.prefix]
- const add = paths.map(path => `file:${path}`)
+ const add = paths.map(path => `file:${path.replace(/#/g, '%23')}`)
const globalTop = resolve(this.npm.globalDir, '..')
const arb = new Arborist({
...this.npm.flatOptions,