提交 3a6811da 编写于 作者: Q qiang

fix: 解决 svg 或非 base64 格式的 Data URI 无法使用的问题 fixed #668

上级 402c2f28
...@@ -344,7 +344,7 @@ export default { ...@@ -344,7 +344,7 @@ export default {
if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !== if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !==
0) { 0) {
loadFile(src) loadFile(src)
} else if (/^data:[a-z-]+\/[a-z-]+;base64,/.test(src)) { } else if (/^data:.*,.*/.test(src)) {
sefl._images[src].src = src sefl._images[src].src = src
} else { } else {
loadUrl(src) loadUrl(src)
......
import getRealRoute from 'uni-helpers/get-real-route' import getRealRoute from 'uni-helpers/get-real-route'
const SCHEME_RE = /^([a-z-]+:)?\/\//i const SCHEME_RE = /^([a-z-]+:)?\/\//i
const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ const DATA_RE = /^data:.*,.*/
function addBase (filePath) { function addBase (filePath) {
return filePath return filePath
...@@ -16,7 +16,7 @@ export default function getRealPath (filePath) { ...@@ -16,7 +16,7 @@ export default function getRealPath (filePath) {
} }
} }
// 网络资源或base64 // 网络资源或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 return filePath
} }
......
...@@ -44,7 +44,7 @@ const _handleLocalPath = filePath => { ...@@ -44,7 +44,7 @@ const _handleLocalPath = filePath => {
export function getRealPath (filePath) { export function getRealPath (filePath) {
const SCHEME_RE = /^([a-z-]+:)?\/\//i const SCHEME_RE = /^([a-z-]+:)?\/\//i
const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ const DATA_RE = /^data:.*,.*/
// 无协议的情况补全 https // 无协议的情况补全 https
if (filePath.indexOf('//') === 0) { if (filePath.indexOf('//') === 0) {
...@@ -52,7 +52,7 @@ export function getRealPath (filePath) { ...@@ -52,7 +52,7 @@ export function getRealPath (filePath) {
} }
// 网络资源或base64 // 网络资源或base64
if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath)) { if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath)) {
return filePath return filePath
} }
......
import getRealRoute from 'uni-helpers/get-real-route' import getRealRoute from 'uni-helpers/get-real-route'
const SCHEME_RE = /^([a-z-]+:)?\/\//i const SCHEME_RE = /^([a-z-]+:)?\/\//i
const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ const DATA_RE = /^data:.*,.*/
function addBase (filePath) { function addBase (filePath) {
if (__uniConfig.router.base) { if (__uniConfig.router.base) {
...@@ -19,7 +19,7 @@ export default function getRealPath (filePath) { ...@@ -19,7 +19,7 @@ export default function getRealPath (filePath) {
} }
} }
// 网络资源或base64 // 网络资源或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 return filePath
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册