Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't add trailing slash to registry URLs (#4032)
- Loading branch information
Showing
11 changed files
with
49 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@pnpm/config": patch | ||
"@pnpm/normalize-registries": patch | ||
--- | ||
|
||
When normalizing registry URLs, a trailing slash should only be added if the registry URL has no path. | ||
|
||
So `https://registry.npmjs.org` is changed to `https://registry.npmjs.org/` but `https://npm.pkg.github.com/owner` is unchanged. | ||
|
||
Related issue: [#4034](https://github.com/pnpm/pnpm/issues/4034). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"pnpm": patch | ||
--- | ||
|
||
pnpm should read the auth token of a github-registry-hosted package, when the registry path contains the owner [#4034](https://github.com/pnpm/pnpm/issues/4034). | ||
|
||
So this should work: | ||
|
||
``` | ||
@owner:registry=https://npm.pkg.github.com/owner | ||
//npm.pkg.github.com/:_authToken=<token> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import normalizeRegistryUrl from 'normalize-registry-url' | ||
|
||
export default function getScopeRegistries (rawConfig: Object) { | ||
const registries = {} | ||
for (const configKey of Object.keys(rawConfig)) { | ||
if (configKey[0] === '@' && configKey.endsWith(':registry')) { | ||
registries[configKey.substr(0, configKey.indexOf(':'))] = normalizeRegistry(rawConfig[configKey]) | ||
registries[configKey.substr(0, configKey.indexOf(':'))] = normalizeRegistryUrl(rawConfig[configKey]) | ||
} | ||
} | ||
return registries | ||
} | ||
|
||
export function normalizeRegistry (registry: string) { | ||
return registry.endsWith('/') ? registry : `${registry}/` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@foo:registry=https://foo.com | ||
@bar:registry=https://bar.com | ||
@qar:registry=https://qar.com/qar | ||
registry=https://default.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.