File size: 649 Bytes
bc20498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import SOURCEMAPPING_URL from './sourceMappingURL.js';

export default function getSourceMappingUrl ( str ) {
	var index, substring, url, match;

	// assume we want the last occurence
	index = str.lastIndexOf( `${SOURCEMAPPING_URL}=` );

	if ( index === -1 ) {
		return null;
	}

	substring = str.substring( index + 17 );
	match = /^[^\r\n]+/.exec( substring );

	url = match ? match[0] : null;

	// possibly a better way to do this, but we don't want to exclude whitespace
	// from the sourceMappingURL because it might not have been correctly encoded
	if ( url && url.slice( -2 ) === '*/' ) {
		url = url.slice( 0, -2 ).trim();
	}

	return url;
}