Skip to content

Commit 2383deb

Browse files
authored
fix: clean urls from arborist, owner, and ping commands (#6037)
1 parent fe9debd commit 2383deb

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

lib/commands/owner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Owner extends BaseCommand {
120120
this.npm.output(maintainers.map(m => `${m.name} <${m.email}>`).join('\n'))
121121
}
122122
} catch (err) {
123-
log.error('owner ls', "Couldn't get owner data", pkg)
123+
log.error('owner ls', "Couldn't get owner data", npmFetch.cleanUrl(pkg))
124124
throw err
125125
}
126126
}

lib/commands/ping.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { cleanUrl } = require('npm-registry-fetch')
12
const log = require('../utils/log-shim')
23
const pingUtil = require('../utils/ping.js')
34
const BaseCommand = require('../base-command.js')
@@ -8,14 +9,15 @@ class Ping extends BaseCommand {
89
static name = 'ping'
910

1011
async exec (args) {
11-
log.notice('PING', this.npm.config.get('registry'))
12+
const cleanRegistry = cleanUrl(this.npm.config.get('registry'))
13+
log.notice('PING', cleanRegistry)
1214
const start = Date.now()
1315
const details = await pingUtil({ ...this.npm.flatOptions })
1416
const time = Date.now() - start
1517
log.notice('PONG', `${time}ms`)
1618
if (this.npm.config.get('json')) {
1719
this.npm.output(JSON.stringify({
18-
registry: this.npm.config.get('registry'),
20+
registry: cleanRegistry,
1921
time,
2022
details,
2123
}, null, 2))

workspaces/arborist/lib/arborist/build-ideal-tree.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const { readdirScoped } = require('@npmcli/fs')
1212
const { lstat, readlink } = require('fs/promises')
1313
const { depth } = require('treeverse')
1414
const log = require('proc-log')
15+
const { cleanUrl } = require('npm-registry-fetch')
1516

1617
const {
1718
OK,
@@ -1210,7 +1211,8 @@ This is a one-time fix-up, please be patient...
12101211
if (this[_manifests].has(spec.raw)) {
12111212
return this[_manifests].get(spec.raw)
12121213
} else {
1213-
log.silly('fetch manifest', spec.raw)
1214+
const cleanRawSpec = cleanUrl(spec.rawSpec)
1215+
log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
12141216
const p = pacote.manifest(spec, options)
12151217
.then(mani => {
12161218
this[_manifests].set(spec.raw, mani)

workspaces/arborist/lib/place-dep.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
const localeCompare = require('@isaacs/string-locale-compare')('en')
1111
const log = require('proc-log')
12+
const { cleanUrl } = require('npm-registry-fetch')
1213
const deepestNestingTarget = require('./deepest-nesting-target.js')
1314
const CanPlaceDep = require('./can-place-dep.js')
1415
const {
@@ -187,7 +188,7 @@ class PlaceDep {
187188
`${this.dep.name}@${this.dep.version}`,
188189
this.canPlace.description,
189190
`for: ${this.edge.from.package._id || this.edge.from.location}`,
190-
`want: ${this.edge.spec || '*'}`
191+
`want: ${cleanUrl(this.edge.spec || '*')}`
191192
)
192193

193194
const placementType = this.canPlace.canPlace === CONFLICT

0 commit comments

Comments
 (0)