Browse Source

prevent false positives for sourcemapping url comments with newlines (#988)

gh-1008
Rich-Harris 8 years ago
parent
commit
1ca90bd374
  1. 2
      src/Bundle.js
  2. 2
      src/Module.js
  3. 3
      test/function/sourcemapping-url-multiline/_config.js
  4. 6
      test/function/sourcemapping-url-multiline/main.js

2
src/Bundle.js

@ -429,7 +429,7 @@ export default class Bundle {
const bundleSourcemapChain = [];
code = transformBundle( code, this.plugins, bundleSourcemapChain, options )
.replace( new RegExp( `^\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'gm' ), '' );
.replace( new RegExp( `^\\/\\/# +${SOURCEMAPPING_URL}=.+\\n?`, 'gm' ), '' );
if ( options.sourceMap ) {
timeStart( 'sourceMap' );

2
src/Module.js

@ -72,7 +72,7 @@ export default class Module {
});
// remove existing sourceMappingURL comments
const pattern = new RegExp( `^\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'gm' );
const pattern = new RegExp( `^\\/\\/# +${SOURCEMAPPING_URL}=.+\\n?`, 'gm' );
let match;
while ( match = pattern.exec( code ) ) {
this.magicString.remove( match.index, match.index + match[0].length );

3
test/function/sourcemapping-url-multiline/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'does not mistakenly recognise sourceMappingURL comment with newline'
};

6
test/function/sourcemapping-url-multiline/main.js

@ -0,0 +1,6 @@
var sourceMappingURL;
//#
sourceMappingURL='something';
assert.equal( sourceMappingURL, 'something' );
Loading…
Cancel
Save