Skip to content

Commit

Permalink
fix(FileAnalyzer): update regex to find top level keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuuGan committed Sep 10, 2019
1 parent 1bcd6ea commit 10d1e60
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fileAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class FileAnalyzer {
*
*/
analyzeExports(contents: string): FileAnalyzerExportsResult[] {
const exportRegex = /(contract|library|interface)\s+([a-zA-Z_$][a-zA-Z_$0-9]*)\s*([\s\S]*?)\{/g;
const exportRegex = /(contract|library|interface)\s+([a-zA-Z_$][a-zA-Z_$0-9]*)\s*([^"]*?)\{/g;
const results = [];
let group: RegExpExecArray;
while ((group = exportRegex.exec(contents))) {
Expand Down
4 changes: 4 additions & 0 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ describe('Solidity Merger', () => {
const result = await merge(file);
assertWithFile(result, 'LocalImports.sol');
});

it('should not find keywords in strings', async () => {
await testFile('ReservedWordsInString');
});
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"importHelpers": false,
"target": "es6",
"module": "commonjs",
"typeRoots": ["node_modules/@types"],
Expand Down

0 comments on commit 10d1e60

Please sign in to comment.