-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stripping of comments with double quotes is not woking #49
base: master
Are you sure you want to change the base?
Conversation
…he issue in removing comments
…he issue in removing comments
…he issue in removing comments
@@ -5,7 +5,7 @@ const languages = require('./languages'); | |||
|
|||
const constants = { | |||
ESCAPED_CHAR_REGEX: /^\\./, | |||
QUOTED_STRING_REGEX: /^(['"`])((?:\\.|[^\1])+?)(\1)/, | |||
QUOTED_STRING_REGEX:/^(['"`])((?:|[^\1])+?)(\1)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after QUOTED_STRING_REGEX:
And I think the +
should be inside, after the closing angle bracket ((?:[^\1]+)?)
and remove the |
content: "Content At quoted String comments"; | ||
content: ""; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something bothers me about that file :D Why it has duplicate stuff? At least we can make it with different classes and different comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to replicate multiple scenarios. Will modify :)
### Description Based on the discussion ChainSafe/filsnap#88 and some further investigation, I realized that the problem origin is inside the library used for stripping comments. The problem occurs if there are double quotes inside the comment, and this issue has been created inside `strip-comments` lib (jonschlinkert/strip-comments#49). Unfortunately, this PR with the fix is stale for some time now, so inside our fork of snaps-cli we used a forked version of `strip-comments` library. ### Changes In this PR I replaced `strip-comments` with our [fork](https://github.com/NodeFactoryIo/strip-comments) that: - fixes a bug with double quotes inside the comment - already contains types, so no need for importing them Co-authored-by: Mak Muftic <mak@chainsafe.io>
When a content of string contains empty qutoes and followed by a comment with a quote, the entire thing is getting matched, causing the comments to left over in the file


Modified regex for identifying the quotes