@@ -136,13 +136,11 @@ exports.init = function(grunt) {
136
136
// Add the lines of a given file to the sourcemap. If in the file, store a
137
137
// prior sourcemap and return src with sourceMappingURL removed.
138
138
SourceMapConcatHelper . prototype . addlines = function ( src , filename ) {
139
+ var sourceMapRegEx = / \n \/ [ * / ] [ @ # ] \s + s o u r c e M a p p i n g U R L = ( (?: (? ! \s + \* \/ ) .) * ) .* / ;
139
140
var relativeFilename = path . relative ( path . dirname ( this . dest ) , filename ) ;
140
141
// sourceMap path references are URLs, so ensure forward slashes are used for paths passed to sourcemap library
141
142
relativeFilename = relativeFilename . replace ( / \\ / g, '/' ) ;
142
- if (
143
- / \/ \/ [ @ # ] \s + s o u r c e M a p p i n g U R L = ( .+ ) / . test ( src ) ||
144
- / \/ \* # \s + s o u r c e M a p p i n g U R L = ( \S + ) \s + \* \/ / . test ( src )
145
- ) {
143
+ if ( sourceMapRegEx . test ( src ) ) {
146
144
var sourceMapFile = RegExp . $1 ;
147
145
var sourceMapPath ;
148
146
@@ -154,7 +152,7 @@ exports.init = function(grunt) {
154
152
sourceContent = new Buffer ( RegExp . $2 , 'base64' ) . toString ( ) ;
155
153
} else {
156
154
// If sourceMapPath is relative, expand relative to the file
157
- // refering to it.
155
+ // referring to it.
158
156
sourceMapPath = path . resolve ( path . dirname ( filename ) , sourceMapFile ) ;
159
157
sourceContent = grunt . file . read ( sourceMapPath ) ;
160
158
}
@@ -197,7 +195,7 @@ exports.init = function(grunt) {
197
195
}
198
196
}
199
197
// Remove the old sourceMappingURL.
200
- src = src . replace ( / [ @ # ] \s + s o u r c e M a p p i n g U R L = [ ^ \s ] + / , '' ) ;
198
+ src = src . replace ( sourceMapRegEx , '' ) ;
201
199
} else {
202
200
// Otherwise perform a rudimentary tokenization of the source.
203
201
this . _forEachTokenPosition ( src , relativeFilename , this . addMapping ) ;
0 commit comments