@@ -32,14 +32,17 @@ test('Should strip sourcemaps by default', async () => {
3232 outDirAssets . find ( ( f ) => / ^ i n d e x - .* \. j s $ / . test ( f ) ) ,
3333 ) ;
3434 const outputChunkCode = await fs . readFile ( outputChunk , 'utf-8' ) ;
35- assert . is ( outputChunkCode . match ( / \/ \/ # \s s o u r c e M a p p i n g U R L = ( .* ) / ) , null ) ;
35+ // Ensure arbitrary strings don't get stripped
36+ assert . ok ( outputChunkCode . match ( / \/ \/ # \s s o u r c e M a p p i n g U R L = / ) ) ;
37+ // Ensure the sourcemap comment has been removed
38+ assert . is ( outputChunkCode . match ( / ^ \/ \/ # \s s o u r c e M a p p i n g U R L = .* \. m a p $ / m) , null ) ;
3639
3740 const outputAsset = path . join (
3841 outDir ,
3942 outDirAssets . find ( ( f ) => / ^ w o r k e r - .* \. j s $ / . test ( f ) ) ,
4043 ) ;
4144 const outputAssetSource = await fs . readFile ( outputAsset , 'utf-8' ) ;
42- assert . is ( outputAssetSource . match ( / \/ \/ # \s s o u r c e M a p p i n g U R L = ( . * ) / ) , null ) ;
45+ assert . is ( outputAssetSource . match ( / ^ \/ \/ # \s s o u r c e M a p p i n g U R L = . * \. m a p $ / m ) , null ) ;
4346} ) ;
4447
4548test ( 'Should preserve sourcemaps if user has enabled them' , async ( ) => {
@@ -64,7 +67,7 @@ test('Should preserve sourcemaps if user has enabled them', async () => {
6467 const outputJs = await fs . readFile ( path . join ( outDir , outputJsFileName ) , 'utf-8' ) ;
6568 assert . match ( outputJs , '//# sourceMappingURL=' ) ;
6669
67- const outputMap = outputJs . match ( / \/ \/ # \s s o u r c e M a p p i n g U R L = ( .* ) / ) [ 1 ] ;
70+ const outputMap = outputJs . match ( / ^ \/ \/ # \s s o u r c e M a p p i n g U R L = ( .* ) \. m a p $ / m ) [ 1 ] ;
6871 assert . ok ( outDirAssets . includes ( outputMap ) ) ;
6972} ) ;
7073
0 commit comments