Skip to content
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

Change RegExp to be less greedy (Fixes #87). #88

Merged
merged 1 commit into from Jul 27, 2015
Merged

Change RegExp to be less greedy (Fixes #87). #88

merged 1 commit into from Jul 27, 2015

Conversation

ghost
Copy link

@ghost ghost commented Jul 27, 2015

Change RegExp to be less greedy (Fixes #87). Add test and allow tests to run (and pass) on Windows.

@@ -84,7 +84,7 @@ function retrieveSourceMapURL(source) {

// Get the URL of the source map
fileData = retrieveFile(source);
var re = /\/\/[#@]\s*sourceMappingURL=([^'"]+)\s*$/mg;
var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so complex, wouldn't a simple non greedy \s*? at the end be enough?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because i took it from an other source map related project. It is in production, tested and it works.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am reluctant to had such a complex and not commented regexp…

From which project does it come from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already better with their comment above the regexp but I don't understand it fully, especially the {1}
I wonder if this regexp should not be in this own package like ip-regex.

Anyway, are you sure all tests pass, even those in browsers?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, except the browserify one but that one was already broken.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the syntax regarding {1} see the Quantifiers table (row x{n}) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, and for me {1} is useless as it is the default behaviour to match one instance…

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the tests from convert-source-map without the {1} and it seems non-significant.

Please let me know if you plan on merging this (without or without the {1}) because for me this is a blocking issue otherwise i need to start looking for an alternative.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can merge this but only @evanw is able to publish a new version.

Before merging this, please remove the {1} and add the comment above the regex.

@julien-f
Copy link
Collaborator

Also, why have you changed all the tests?

@ghost
Copy link
Author

ghost commented Jul 27, 2015

So it is now possible to execute the tests on Windows.

@julien-f
Copy link
Collaborator

I undertand but it should be in a separate pull request.

@ghost
Copy link
Author

ghost commented Jul 27, 2015

Partly reverted the test changes and created an issue #89 for it.

@julien-f
Copy link
Collaborator

Squashes your commits and we good to go.

julien-f added a commit that referenced this pull request Jul 27, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Change RegExp to be less greedy (Fixes #87).
@julien-f julien-f merged commit 6296f61 into evanw:master Jul 27, 2015
@julien-f
Copy link
Collaborator

Merged, you can now use it by installing the package from github (npm i evanw/node-source-map-support) or open an issue to ask @evanw for a new release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants