Skip to content

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.

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.

It is from the convert-source-map project
https://www.npmjs.com/package/convert-source-map
The RegExp is on the following line:
https://github.com/thlorenz/convert-source-map/blob/master/index.js#L8

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
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.

2 participants