Skip to content

Commit

Permalink
Fix: Fix regex so single-character @scopes can work again (#4338)
Browse files Browse the repository at this point in the history
**Summary**

The exotic `file-resolver` checks for `.` and `..`, but the regex is missing the escape on the `.`, so *any* two characters count as a file. This includes single-character scope names, like `@s/packagename`.

This issue was introduced in #4257.

**Test plan**

I wasn't sure how packages should be named in `__tests__/fixtures/install/resolutions/exotic-version`, so I have not added add a single-character scoped package reference to test.

I don't know of any single-character scopes in the public registry to use as reference, the way `left-pad-1.1.1.tgz` is mirrored in there. Could I just copy `leftpad-1.1.1.tgz` as `@s/leftpad-1.1.1.tgz` and use that?
  • Loading branch information
dylang authored and BYK committed Sep 8, 2017
1 parent 5ea8ea7 commit 6295408
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/resolvers/exotics/file-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class FileResolver extends ExoticResolver {
loc: string;

static protocol = 'file';
static prefixMatcher = /^.{1,2}\//;
static prefixMatcher = /^\.{1,2}\//;

static isVersion(pattern: string): boolean {
return super.isVersion.call(this, pattern) || this.prefixMatcher.test(pattern) || path.isAbsolute(pattern);
Expand Down

0 comments on commit 6295408

Please sign in to comment.