Skip to content

Commit

Permalink
Merge pull request #532 from GilgameshxZero/bugfix-path-regex-char
Browse files Browse the repository at this point in the history
Escape special regex characters in library path scan
  • Loading branch information
martpie authored May 5, 2020
2 parents 025856d + 1725e8a commit 8876c98
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ui/actions/LibraryActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ export const add = async (pathsToScan: string[]) => {

// 3. Scan all the directories with globby
const globbies = folders.map((folder) => {
const pattern = `${folder.replace(/\\/g, '/')}/**/*.*`;
// Normalize slashes and escape regex special characters
const pattern = `${folder.replace(/\\/g, '/').replace(/([$^*+?()\[\]])/g, '\\$1')}/**/*.*`;

console.log(pattern);
return globby(pattern, { followSymbolicLinks: true });
Expand Down

0 comments on commit 8876c98

Please sign in to comment.