@blueking/bk-weweb 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,11 +94,7 @@ function resetDocumentPrototypeMethods() {
94
94
 
95
95
  const nextTask = cb => Promise.resolve().then(cb);
96
96
  function addUrlProtocol(url) {
97
- if (url.startsWith('//'))
98
- return `${location.protocol}${url}`;
99
- if (!url.startsWith('http'))
100
- return `${location.protocol}//${url}`;
101
- return url;
97
+ return url.startsWith('//') ? `${location.protocol}${url}` : url;
102
98
  }
103
99
  // 补齐url地址
104
100
  function fillUpPath(path, baseURI) {
@@ -121,9 +117,7 @@ const random = (n, str = 'abcdefghijklmnopqrstuvwxyz0123456789') => {
121
117
  return result;
122
118
  };
123
119
  const isJsonpUrl = (url) => {
124
- if (!url)
125
- return false;
126
- if (url.match(/\.js$/))
120
+ if (!url || url.match(/\.js$/))
127
121
  return false;
128
122
  const { pathname } = new URL(addUrlProtocol(url));
129
123
  return !pathname.match(/\.js$/);
@@ -1757,7 +1751,7 @@ class MicroAppModel {
1757
1751
  createIframe() {
1758
1752
  return new Promise((resolve) => {
1759
1753
  const iframe = document.createElement('iframe');
1760
- const url = new URL(addUrlProtocol(this.url));
1754
+ const url = new URL(this.url);
1761
1755
  const isChrome = navigator.userAgent.indexOf('Chrome') > -1;
1762
1756
  iframe.setAttribute('src', `${isChrome ? BLANK_ORIGN : location.origin}${url.pathname || '/'}${url.search}${url.hash}`);
1763
1757
  iframe.style.cssText = 'display: none;';
@@ -1815,7 +1809,7 @@ class EntrySource {
1815
1809
  async importHtmlEntry(app) {
1816
1810
  let htmlStr = appCache.getCacheHtml(this.url);
1817
1811
  if (!htmlStr) {
1818
- htmlStr = await fetchSource(addUrlProtocol(this.url), { cache: 'no-cache' });
1812
+ htmlStr = await fetchSource(this.url, { cache: 'no-cache' });
1819
1813
  if (!htmlStr) {
1820
1814
  console.error('load app entry error, pleace check');
1821
1815
  return Promise.reject();