瀏覽代碼

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

mayingcong 3 年之前
父節點
當前提交
886541ab35
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/index.ts

+ 3 - 0
src/index.ts

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