Merge pull request #160 from six-ponies/fix/import-script-protocol-error

fix: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL xxx is invalid.
pull/2748/head
Alexandru Dima 3 years ago committed by GitHub
commit 6a882e9569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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