Skip to content

Commit

Permalink
Merge pull request #26 from pmb0/fix/empty-string-bug
Browse files Browse the repository at this point in the history
Fix empty string gobbling too much of the file
  • Loading branch information
Brian-McBride committed May 20, 2023
2 parents 8d1d4e1 + 1326202 commit e1a7094
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Expand Up @@ -4,6 +4,8 @@ THIS_

SHOULD_['This is a string used as a key']

REALLY_ = ''

/*
* None of this should catch a @element in a comment.
*/
Expand Down
6 changes: 4 additions & 2 deletions packages/esbuild-decorators/src/__tests__/strip-it.spec.ts
Expand Up @@ -9,9 +9,11 @@ describe(`Strip It`, () => {
);

const result = strip(testFile)
.replace(/[:[\]\n]|\s*/g, '')
.replace(/[:=[\]\n]|\s*/g, '')
.replace(/_/g, ' ');

expect(result).toEqual(`THIS SHOULD ALL BE WHAT'S LEFT OF THE ENTIRE FILE`);
expect(result).toEqual(
`THIS SHOULD REALLY ALL BE WHAT'S LEFT OF THE ENTIRE FILE`
);
});
});
2 changes: 1 addition & 1 deletion packages/esbuild-decorators/src/lib/strip-it.ts
Expand Up @@ -53,7 +53,7 @@ class TextBlock extends TextNode {

const constants = {
ESCAPED_CHAR_REGEX: /^\\./,
QUOTED_STRING_REGEX: /^(['"`])((?:\\.|[^\1])+?)(\1)/,
QUOTED_STRING_REGEX: /^(['"`])((?:\\.|[^\1])*?)(\1)/,
NEWLINE_REGEX: /^\r*\n/,
BLOCK_OPEN_REGEX: /^\/\*\*?(!?)/,
BLOCK_CLOSE_REGEX: /^\*\/(\n?)/,
Expand Down

0 comments on commit e1a7094

Please sign in to comment.