fix: import scripts error when url starts with '//'

pull/2748/head
mayingcong 4 years ago
parent e4629337d5
commit 886541ab35

@ -234,6 +234,9 @@ function createLoaderRules(languages: IFeatureDefinition[], features: IFeatureDe
var currentUrl = String(window.location);
var currentOrigin = currentUrl.substr(0, currentUrl.length - window.location.hash.length - window.location.search.length - window.location.pathname.length);
if (result.substring(0, currentOrigin.length) !== currentOrigin) {
if(/^(\\/\\/)/.test(result)) {
result = window.location.protocol + result
}
var js = '/*' + label + '*/importScripts("' + result + '");';
var blob = new Blob([js], { type: 'application/javascript' });
return URL.createObjectURL(blob);

Loading…
Cancel
Save