File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,8 @@ function retrieveSourceMapURL(source) {
84
84
85
85
// Get the URL of the source map
86
86
fileData = retrieveFile ( source ) ;
87
- var re = / \/ \/ [ # @ ] \s * s o u r c e M a p p i n g U R L = ( [ ^ ' " ] + ) \s * $ / mg;
87
+ // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */
88
+ var re = / (?: \/ \/ [ @ # ] [ \t ] + s o u r c e M a p p i n g U R L = ( [ ^ \s ' " ] + ?) [ \t ] * $ ) | (?: \/ \* [ @ # ] [ \t ] + s o u r c e M a p p i n g U R L = ( [ ^ \* ] + ?) [ \t ] * (?: \* \/ ) [ \t ] * $ ) / mg;
88
89
// Keep executing the search to find the *last* sourceMappingURL to avoid
89
90
// picking up sourceMappingURLs from comments, strings, etc.
90
91
var lastMatch , match ;
Original file line number Diff line number Diff line change @@ -416,6 +416,31 @@ it('finds source maps with charset specified', function() {
416
416
fs . unlinkSync ( '.generated.js' ) ;
417
417
} ) ;
418
418
419
+ /* The following test duplicates some of the code in
420
+ * `compareStackTrace` but appends some code and a
421
+ * comment to the source mapping url.
422
+ */
423
+ it ( 'allows code/comments after sourceMappingURL' , function ( ) {
424
+ var sourceMap = createMultiLineSourceMap ( )
425
+ var source = [ 'throw new Error("test");' ] ;
426
+ var expected = [
427
+ 'Error: test' ,
428
+ / ^ a t O b j e c t \. e x p o r t s \. t e s t \( .* \/ l i n e 1 \. j s : 1 0 0 1 : 1 0 1 \) $ /
429
+ ] ;
430
+
431
+ fs . writeFileSync ( '.generated.js' , 'exports.test = function() {' +
432
+ source . join ( '\n' ) + '};//# sourceMappingURL=data:application/json;base64,' +
433
+ new Buffer ( sourceMap . toString ( ) ) . toString ( 'base64' ) +
434
+ '\n// Some comment below the sourceMappingURL\nvar foo = 0;' ) ;
435
+ try {
436
+ delete require . cache [ require . resolve ( './.generated' ) ] ;
437
+ require ( './.generated' ) . test ( ) ;
438
+ } catch ( e ) {
439
+ compareLines ( e . stack . split ( '\n' ) , expected ) ;
440
+ }
441
+ fs . unlinkSync ( '.generated.js' ) ;
442
+ } ) ;
443
+
419
444
it ( 'handleUncaughtExceptions is true with existing listener' , function ( done ) {
420
445
var source = [
421
446
'process.on("uncaughtException", function() { /* Silent */ });' ,
You can’t perform that action at this time.
0 commit comments