diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue index d1a39d8dd90..a5babc47667 100644 --- a/src/core/view/components/canvas/index.vue +++ b/src/core/view/components/canvas/index.vue @@ -344,7 +344,7 @@ export default { if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !== 0) { loadFile(src) - } else if (/^data:[a-z-]+\/[a-z-]+;base64,/.test(src)) { + } else if (/^data:.*,.*/.test(src)) { sefl._images[src].src = src } else { loadUrl(src) diff --git a/src/platforms/app-plus/helpers/get-real-path.js b/src/platforms/app-plus/helpers/get-real-path.js index 72033e8eeb5..78ead12c6f4 100644 --- a/src/platforms/app-plus/helpers/get-real-path.js +++ b/src/platforms/app-plus/helpers/get-real-path.js @@ -1,7 +1,7 @@ import getRealRoute from 'uni-helpers/get-real-route' const SCHEME_RE = /^([a-z-]+:)?\/\//i -const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ +const DATA_RE = /^data:.*,.*/ function addBase (filePath) { return filePath @@ -16,7 +16,7 @@ export default function getRealPath (filePath) { } } // 网络资源或base64 - if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath) || filePath.indexOf('blob:') === 0) { + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) { return filePath } diff --git a/src/platforms/app-plus/service/api/util.js b/src/platforms/app-plus/service/api/util.js index e6221cfbfe4..d7c3d97a198 100644 --- a/src/platforms/app-plus/service/api/util.js +++ b/src/platforms/app-plus/service/api/util.js @@ -44,7 +44,7 @@ const _handleLocalPath = filePath => { export function getRealPath (filePath) { const SCHEME_RE = /^([a-z-]+:)?\/\//i - const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ + const DATA_RE = /^data:.*,.*/ // 无协议的情况补全 https if (filePath.indexOf('//') === 0) { @@ -52,7 +52,7 @@ export function getRealPath (filePath) { } // 网络资源或base64 - if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath)) { + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath)) { return filePath } diff --git a/src/platforms/h5/helpers/get-real-path.js b/src/platforms/h5/helpers/get-real-path.js index 56b04864539..0b018beca44 100644 --- a/src/platforms/h5/helpers/get-real-path.js +++ b/src/platforms/h5/helpers/get-real-path.js @@ -1,7 +1,7 @@ import getRealRoute from 'uni-helpers/get-real-route' const SCHEME_RE = /^([a-z-]+:)?\/\//i -const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ +const DATA_RE = /^data:.*,.*/ function addBase (filePath) { if (__uniConfig.router.base) { @@ -19,7 +19,7 @@ export default function getRealPath (filePath) { } } // 网络资源或base64 - if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath) || filePath.indexOf('blob:') === 0) { + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) { return filePath }