@@ -84,7 +84,7 @@ test('contentOrFile rejects wrong remote url', t => {
8484test ( 'contentOrFile reads local js file' , t => {
8585 const path = 'a.js' ;
8686
87- contentOrFile ( path , { readFile : buildReadFile ( { 'a.js' : 'var a;\n//# sourceMappingURL=abc' } ) } )
87+ contentOrFile ( path , { readFile : buildReadFile ( { 'a.js' : 'var a;\n//# sourceMappingURL=data:application/json;base64, abc' } ) } )
8888 . then (
8989 result => {
9090 t . equal ( result . contents , 'var a;' ) ;
@@ -127,17 +127,23 @@ test('generateHash generates hash', t => {
127127 t . end ( ) ;
128128} ) ;
129129
130+ test ( 'stripSourceMappingUrl does not strip sourceMappingURL inside js string' , t => {
131+ const code = `"\\n/*# sourceMappingURL=data:application/json;base64,".concat(map," */");` ;
132+ t . equal ( stripSourceMappingUrl ( code ) , code ) ;
133+ t . end ( ) ;
134+ } )
135+
130136test ( 'stripSourceMappingUrl strips js sourcemapping url' , t => {
131137 t . equal ( stripSourceMappingUrl ( 'lorem\n' ) , 'lorem\n' ) ;
132- t . equal ( stripSourceMappingUrl ( 'lorem\n//# sourceMappingURL=abc123' ) , 'lorem\n' ) ;
133- t . equal ( stripSourceMappingUrl ( 'lorem\n//# sourceMappingURL=abc123\nfoo\n//# sourceMappingURL=xyz' ) , 'lorem\n\nfoo\n' ) ;
138+ t . equal ( stripSourceMappingUrl ( 'lorem\n//# sourceMappingURL=data:application/json;base64, abc123' ) , 'lorem\n' ) ;
139+ t . equal ( stripSourceMappingUrl ( 'lorem\n//# sourceMappingURL=data:application/json;base64, abc123\nfoo\n//# sourceMappingURL=data:application/json;base64, xyz' ) , 'lorem\n\nfoo\n' ) ;
134140 t . end ( ) ;
135141} ) ;
136142
137143test ( 'stripSourceMappingUrl strips css sourcemapping url' , t => {
138144 t . equal ( stripSourceMappingUrl ( 'lorem\n' ) , 'lorem\n' ) ;
139- t . equal ( stripSourceMappingUrl ( 'lorem\n/*# sourceMappingURL=abc123 */' ) , 'lorem\n' ) ;
140- t . equal ( stripSourceMappingUrl ( 'lorem\n/*# sourceMappingURL=abc123 */\nfoo\n/*# sourceMappingURL=xyz */' ) , 'lorem\n\nfoo\n' ) ;
145+ t . equal ( stripSourceMappingUrl ( 'lorem\n/*# sourceMappingURL=data:application/json;base64, abc123 */' ) , 'lorem\n' ) ;
146+ t . equal ( stripSourceMappingUrl ( 'lorem\n/*# sourceMappingURL=data:application/json;base64, abc123 */\nfoo\n/*# sourceMappingURL=data:application/json;base64, xyz */' ) , 'lorem\n\nfoo\n' ) ;
141147 t . end ( ) ;
142148} ) ;
143149
0 commit comments