-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: support protocol-relative registry URLs #4347
Conversation
**Summary** Fixes matching protocol-relative registry URLs from config. Reported here: #3987 (comment) **Test plan** Added one new test.
src/registries/npm-registry.js
Outdated
@@ -314,8 +314,8 @@ export default class NpmRegistry extends Registry { | |||
// 3nd attempt, remove the 'registry/?' suffix of the registry URL | |||
return ( | |||
this.getScopedOption(reg, option) || | |||
(reg.match(pre) && this.getRegistryOption(reg.replace(pre, ''), option)) || | |||
(reg.match(suf) && this.getRegistryOption(reg.replace(suf, ''), option)) | |||
(pre.test(reg) && !reg.startsWith('//') && this.getRegistryOption(reg.replace(pre, '//'), option)) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this reg.startsWith('//')
check? If it starts with //
the subsequent replace will simply be a noop. This change makes getRegistryOption
not being applied to protocol-relative url, is it intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was due to the regex now matching the whole https://
part instead of just the protocol. We want the //
kept intact but then we need the additional .startsWith()
check to prevent this method from recursing infinitely on the same registry value.
That said I did this to share the same regex with others. I tried adding a comment but it took three lines so instead, I created another regex 😆
**Summary** Fixes matching protocol-relative registry URLs from config. Reported here: yarnpkg#3987 (comment) **Test plan** Added one new test.
Summary
Fixes matching protocol-relative registry URLs from config.
Reported here: #3987 (comment)
Test plan
Added one new test.