8000 Matching the last sourceMappingURL in the file. by fabiomcosta · Pull Request #50 · stacktracejs/stacktrace-gps · GitHub
[go: up one dir, main page]

Skip to content

Matching the last sourceMappingURL in the file. #50

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

Closed

Conversation

fabiomcosta
Copy link

Currently _findSourceMappingURL returns the first sourceMappingURL
uri it finds, but we really want is the last match.

Motivation and Context

I found because on one of my project's bundle in development there is one dependency that is (for some reason) including a sourceMappingURL comment and that uri is being incorrectly returned instead of the bundle's source map.

How Has This Been Tested?

gulp test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • node_modules/.bin/jscs -c .jscsrc stacktrace-gps.js passes without errors
  • npm test passes without errors
  • I have updated the documentation accordingly
  • I have added tests to cover my changes

Currently `_findSourceMappingURL` returns the first `sourceMappingURL`
uri it finds, but we really want is the last match.
return m[1];
} else {
throw new Error('sourceMappingURL not found');
var allMatches = source.match(_reSourceMapping);
Copy link
Author

Choose a reason for hiding this comment

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

Note:
When using a global (g) RegExp with match it returns an array with all the matched ocurrences.
But when using it with exec it seems to ignore the global flag and returns the match groups.

@eriwen
Copy link
Member
eriwen commented Aug 12, 2017

Hi @fabiomcosta, thank you for your PR, and sorry for the late follow-up.

I just happened to get to #53 before this one which solves the same issue and merged it, so this isn't necessary anymore. I think this solution is just as good as the other one, though, so thank you for a high-quality contribution.

A fix for the issue in question has been released in stacktrace-gps v3.0.2 today.

Thanks again.

@fabiomcosta
Copy link
Author
< 9556 div> fabiomcosta commented Aug 13, 2017

Hi @eriwen thank you for your kind response and for this great work that you provide for us all.
It definitely saved me long hours of pain to work around the multiple differences that an error stack has across browsers.

@eriwen
Copy link
Member
eriwen commented Aug 14, 2017

@fabiomcosta thanks for the kind words :)

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

Successfully merging this pull request may close these issues.

3 participants
0