Skip to content

Commit

Permalink
Avoid matching sourceMappingURL inside a template string
Browse files Browse the repository at this point in the history
NOTE: Multi-line template strings are not protected against.

This commit also updates the comment above the 'sourceMappingURL'
regular expression that would cause a false positive when this
library parses itself (which can happen when two packages depend
on this library).
  • Loading branch information
aleclarson committed Nov 23, 2017
1 parent fa92551 commit 46a6c17
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ Object.defineProperty(exports, 'commentRegex', {

Object.defineProperty(exports, 'mapFileCommentRegex', {
get: function getMapFileCommentRegex () {
//Example (Extra space between slashes added to solve Safari bug. Exclude space in production):
// / /# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */
return /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg;
// Matches sourceMappingURL in either // or /* comment styles.
return /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg;
}
});

Expand Down

0 comments on commit 46a6c17

Please sign in to comment.