File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed
Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 101101 }
102102
103103 async function finishLoadingCodeWithEmbeddedSourceMap ( code , file ) {
104- // Check for both "//" and "/*" comments
105- let match = / \/ ( \/ ) [ # @ ] * s o u r c e M a p p i n g U R L = ( [ ^ \s ] + ) / . exec ( code ) ;
106- if ( ! match ) match = / \/ ( \* ) [ # @ ] * s o u r c e M a p p i n g U R L = ( (?: [ ^ \s * ] | \* [ ^ / ] ) + ) (?: [ ^ * ] | \* [ ^ / ] ) * \* \/ / . exec ( code ) ;
104+ let url ;
105+
106+ // Check for both "//" and "/*" comments. This is mostly done manually
107+ // instead of doing it all with a regular expression because Firefox's
108+ // regular expression engine crashes with an internal error when the
109+ // match is too big.
110+ for ( let regex = / \/ ( [ * / ] ) [ # @ ] * s o u r c e M a p p i n g U R L = / g, match ; match = regex . exec ( code ) ; ) {
111+ const start = match . index + match [ 0 ] . length ;
112+ const n = code . length ;
113+ let end = start ;
114+ while ( end < n && code . charCodeAt ( end ) > 32 ) {
115+ end ++ ;
116+ }
117+ if ( end > start && ( match [ 1 ] === '/' || code . slice ( end ) . indexOf ( '*/' ) > 0 ) ) {
118+ url = code . slice ( start , end ) ;
119+ break ;
120+ }
121+ }
107122
108123 // Check for a non-empty data URL payload
109- if ( match && match [ 2 ] ) {
124+ if ( url ) {
110125 let map ;
111126 try {
112127 // Use "new URL" to ensure that the URL has a protocol (e.g. "data:" or "https:")
113- map = await fetch ( new URL ( match [ 2 ] ) ) . then ( r => r . text ( ) ) ;
128+ map = await fetch ( new URL ( url ) ) . then ( r => r . text ( ) ) ;
114129 } catch ( e ) {
115130 showLoadingError ( `Failed to parse the URL in the "/${ match [ 1 ] } # sourceMappingURL=" comment: ${ e && e . message || e } ` ) ;
116131 return ;
You can’t perform that action at this time.
0 commit comments