Fix yarn URL issue

This commit is contained in:
Reinier Criel 2026-03-27 11:45:26 -07:00
parent db31fa9f41
commit a53fc736e9
2 changed files with 6 additions and 2 deletions

View file

@ -127,6 +127,10 @@ describe("npmInterceptor", async () => {
url: "https://registry.yarnpkg.com/@babel/core/-/core-7.21.4.tgz", url: "https://registry.yarnpkg.com/@babel/core/-/core-7.21.4.tgz",
expected: { packageName: "@babel/core", version: "7.21.4" }, expected: { packageName: "@babel/core", version: "7.21.4" },
}, },
{
url: "https://registry.yarnpkg.com/@music-i18n%2fverovio/-/verovio-1.4.1.tgz",
expected: { packageName: "@music-i18n/verovio", version: "1.4.1" },
},
// URL to get package info, not tarball // URL to get package info, not tarball
{ {
url: "https://registry.npmjs.org/lodash", url: "https://registry.npmjs.org/lodash",

View file

@ -12,9 +12,9 @@ export function parseNpmPackageUrl(url, registry) {
} }
const registryIndex = urlWithoutParams.indexOf(registry); const registryIndex = urlWithoutParams.indexOf(registry);
const afterRegistry = urlWithoutParams.substring( const afterRegistry = decodeURIComponent(urlWithoutParams.substring(
registryIndex + registry.length + 1 registryIndex + registry.length + 1
); // +1 to skip the slash )); // +1 to skip the slash
const separatorIndex = afterRegistry.indexOf("/-/"); const separatorIndex = afterRegistry.indexOf("/-/");
if (separatorIndex === -1) { if (separatorIndex === -1) {