Skip to content

Commit

Permalink
fix: fix path replacement regex
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Nov 29, 2017
1 parent 0cb6445 commit 56a74e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ const lfs = link(fs, [





# License

[Unlicense](./LICENSE) - public domain.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function link(fs, rewrites: string[] | string[][]): any {
if(!(rewrites instanceof Array))
throw TypeError('rewrites must be a list of 2-tuples');

// All for only one tuple to be provided.
// If only one tuple is provided.
if(typeof rewrites[0] === 'string')
rewrites = [rewrites] as any as [string, string][];

Expand Down Expand Up @@ -128,7 +128,7 @@ export function link(fs, rewrites: string[] | string[][]): any {
for(const [from, to] of rews) {
if(filename.indexOf(from) === 0) {
// filename = filename.replace(from, to);
const regex = new RegExp('^(' + from.replace('\\', '\\\\') + ')(/|$)');
const regex = new RegExp('^(' + from.replace(/\\/g, '\\\\') + ')(\\\\|\/|$)');
filename = filename.replace(regex, (match, p1, p2, off, str) => to + p2);
}
}
Expand Down

0 comments on commit 56a74e6

Please sign in to comment.