Skip to content

Commit

Permalink
fix: fix unescaped special chararacter in regex
Browse files Browse the repository at this point in the history
- BUG: The unescaped period functions as a wildcard character instead of a plain dot as intended.
- Inside a string or template literal, a period preceded by a single backslash (escape sequence) will be parsed as an unescaped period.
- The string representation of \. is the double-escaped literal "\\."

see also: issue oslabs-beta#85
  • Loading branch information
MajorLift committed Nov 23, 2021
1 parent 509652c commit c039ca2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sapling/src/SaplingParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class SaplingParser {
if (!ext) {
// Try and find file extension that exists in directory:
const fileArray = fs.readdirSync(path.dirname(componentTree.filePath));
const regEx = new RegExp(`${componentTree.fileName}.(j|t)sx?$`);
const regEx = new RegExp(`${componentTree.fileName}\\.(j|t)sx?$`);
fileName = fileArray.find(fileStr => fileStr.match(regEx));
fileName ? componentTree.filePath += path.extname(fileName) : null;
}
Expand Down

0 comments on commit c039ca2

Please sign in to comment.