Skip to content

Fix: support protocol-relative registry URLs#4347

Merged
BYK merged 4 commits intomasterfrom
registry-urls
Sep 8, 2017
Merged

Fix: support protocol-relative registry URLs#4347
BYK merged 4 commits intomasterfrom
registry-urls

Conversation

@BYK
Copy link
Copy Markdown
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.
Comment thread src/registries/npm-registry.js Outdated
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
Copy Markdown
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
Copy Markdown
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.

2 participants