From cc63799d5aa4f53ebdb8d265d2ff351937e70c46 Mon Sep 17 00:00:00 2001 From: Xingwang Liao Date: Tue, 17 Dec 2024 15:16:02 +0800 Subject: [PATCH] fix(api): fix scope handling in package routes (#5006) The changes in #5000 breaks package scopes --- src/api/web/api/package.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/web/api/package.ts b/src/api/web/api/package.ts index fc51313c4..d9c60d053 100644 --- a/src/api/web/api/package.ts +++ b/src/api/web/api/package.ts @@ -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({