0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

fix(api): fix scope handling in package routes (#5006)

The changes in #5000 breaks package scopes
This commit is contained in:
Xingwang Liao 2024-12-17 15:16:02 +08:00 committed by GitHub
parent e841cbe44d
commit cc63799d5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,8 +120,7 @@ function addPackageWebApi(pkgRouter: Router, storage: Storage, auth: Auth, confi
],
can('access'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const rawScope = req.params.scope; // May include '@'
const scope = rawScope ? rawScope.slice(1) : null; // Remove '@' if present
const scope = req.params.scope;
const packageName = scope ? addScope(scope, req.params.package) : req.params.package;
storage.getPackage({
@ -141,11 +140,10 @@ function addPackageWebApi(pkgRouter: Router, storage: Storage, auth: Auth, confi
);
pkgRouter.get(
['/-/verdaccio/data/sidebar/:scope/:package', '/-/verdaccio/data/sidebar/:package'],
['/-/verdaccio/data/sidebar/@:scope/:package', '/-/verdaccio/data/sidebar/:package'],
can('access'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const rawScope = req.params.scope; // May include '@'
const scope = rawScope ? rawScope.slice(1) : null; // Remove '@' if present
const scope = req.params.scope;
const packageName: string = scope ? addScope(scope, req.params.package) : req.params.package;
storage.getPackage({