Skip to content

Commit

Permalink
Fix the scope regex, allow / in addition to %2f in the url
Browse files Browse the repository at this point in the history
  • Loading branch information
KidkArolis committed Sep 8, 2017
1 parent d3f223c commit a029195
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions __tests__/registries/npm-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('isRequestToRegistry functional test', () => {
const packageIdents = [
['normal', ''],
['@scopedNoPkg', ''],
['@scoped/notescaped', ''],
['@scoped/notescaped', '@scoped'],
['not@scope/pkg', ''],
['@scope?query=true', ''],
['@scope%2fpkg', '@scope'],
Expand All @@ -260,13 +260,15 @@ const packageIdents = [
['@scope%2fpkg%2f1.2.3', '@scope'],
['http://foo.bar:80/normal', ''],
['http://foo.bar:80/@scopedNoPkg', ''],
['http://foo.bar:80/@scoped/notescaped', ''],
['http://foo.bar:80/@scoped/notescaped', '@scoped'],
['http://foo.bar:80/@scoped/notescaped/download/@scoped/pkg-1.0.0.tgz', '@scoped'],
['http://foo.bar:80/not@scope/pkg', ''],
['http://foo.bar:80/@scope?query=true', ''],
['http://foo.bar:80/@scope%2fpkg', '@scope'],
['http://foo.bar:80/@scope%2fpkg%2fext', '@scope'],
['http://foo.bar:80/@scope%2fpkg?query=true', '@scope'],
['http://foo.bar:80/@scope%2fpkg%2f1.2.3', '@scope'],
['http://foo.bar:80/@scope%2fpkg/download/@scope%2fpkg-1.0.0.tgz', '@scope'],
];

describe('isScopedPackage functional test', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/registries/npm-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const SCOPE_SEPARATOR = '%2f';
// `(?:^|\/)` Match either the start of the string or a `/` but don't capture
// `[^\/?]+?` Match any character that is not '/' or '?' and capture, up until the first occurance of:
// `%2f` Match SCOPE_SEPARATOR, the escaped '/', and don't capture
const SCOPED_PKG_REGEXP = /(?:^|\/)(@[^\/?]+?)(?=%2f)/;
const SCOPED_PKG_REGEXP = /(?:^|\/)(@[^\/?]+?)(?=%2f|\/)/;

// TODO: Use the method from src/cli/commands/global.js for this instead
function getGlobalPrefix(): string {
Expand Down

0 comments on commit a029195

Please sign in to comment.