Skip to content

Commit

Permalink
feat: escape more url chars
Browse files Browse the repository at this point in the history
list and logic borrowed from escape-string-regexp
  • Loading branch information
w33ble committed Jul 23, 2018
1 parent c0311cf commit bce6b87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/PathUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const stripLeadingSlash = path =>
path.charAt(0) === "/" ? path.substr(1) : path;

export const hasBasename = (path, prefix) =>
new RegExp("^" + prefix.replace(/(\?)/g, '\\$1') + "(\\/|\\?|#|$)", "i").test(path);
new RegExp("^" + prefix.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') + "(\\/|\\?|#|$)", "i").test(path);

export const stripBasename = (path, prefix) =>
hasBasename(path, prefix) ? path.substr(prefix.length) : path;
Expand Down

0 comments on commit bce6b87

Please sign in to comment.