Skip to content
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

Merged
merged 4 commits into from
Sep 8, 2017
Merged

Fix: support protocol-relative registry URLs #4347

merged 4 commits into from
Sep 8, 2017

Conversation

BYK
Copy link
Member

@BYK BYK commented Sep 8, 2017

Summary

Fixes matching protocol-relative registry URLs from config.
Reported here: #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.
@@ -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)) ||
Copy link
Member

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?

Copy link
Member Author

@BYK BYK Sep 8, 2017

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 😆

@BYK BYK merged commit 161f97e into master Sep 8, 2017
@BYK BYK deleted the registry-urls branch September 8, 2017 21:25
@BYK BYK added this to the 1.0.2 milestone Sep 12, 2017
joaolucasl pushed a commit to joaolucasl/yarn that referenced this pull request Oct 27, 2017
**Summary**

Fixes matching protocol-relative registry URLs from config.
Reported here: yarnpkg#3987 (comment)

**Test plan**

Added one new test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants