Skip to content

Commit

Permalink
fix: 修复模板 style 中本地路径包含特殊符号时未处理的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Oct 14, 2020
1 parent fa21137 commit ab9f094
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/platforms/web/runtime/modules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ const transformUnit = (val) => {
return val
}

const urlRE = /url\(\s*'?"?([a-zA-Z0-9\.\-\_\/]+\.(jpg|gif|png))"?'?\s*\)/
const urlRE1 = /url\(\s*['"](.+?\.(jpg|gif|png))['"]\s*\)/
const urlRE2 = /url\(\s*([a-zA-Z0-9\.\-\_\/]+?\.(jpg|gif|png))\s*\)/

const transformUrl = (val, ctx) => {
if (typeof val === 'string' && val.indexOf('url(') !== -1) {
const matches = val.match(urlRE)
const matches = val.match(urlRE1) || val.match(urlRE2)
if (matches && matches.length === 3) {
val = val.replace(matches[1], ctx._$getRealPath(matches[1]))
}
Expand Down

0 comments on commit ab9f094

Please sign in to comment.