mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
Add workaround to handle URLs of scoped packages with unencoded /
Fixes https://github.com/rlidwka/sinopia/issues/104#issuecomment-66790574.
This commit is contained in:
parent
93245c0179
commit
fde2321222
2 changed files with 18 additions and 0 deletions
|
@ -33,6 +33,15 @@ module.exports = function(config, auth, storage) {
|
|||
app.use(expressJson5({ strict: false, limit: config.max_body_size || '10mb' }))
|
||||
app.use(Middleware.anti_loop(config))
|
||||
|
||||
// encode / in a scoped package name to be matched as a single parameter in routes
|
||||
app.use(function(req, res, next) {
|
||||
if (req.url.indexOf('@') != -1) {
|
||||
// e.g.: /@org/pkg/1.2.3 -> /@org%2Fpkg/1.2.3, /@org%2Fpkg/1.2.3 -> /@org%2Fpkg/1.2.3
|
||||
req.url = req.url.replace(/^(\/@[^\/%]+)\/(?!$)/, '$1%2F')
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
// for "npm whoami"
|
||||
app.get('/whoami', function(req, res, next) {
|
||||
if (req.headers.referer === 'whoami') {
|
||||
|
|
|
@ -65,5 +65,14 @@ module.exports = function() {
|
|||
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'})
|
||||
})
|
||||
})
|
||||
|
||||
it('server2 - nginx workaround', function () {
|
||||
return server2.request({ uri: '/@test/scoped/1.0.0' })
|
||||
.status(200)
|
||||
.then(function (body) {
|
||||
assert.equal(body.name, '@test/scoped')
|
||||
assert.equal(body.dist.tarball, 'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz')
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue