postcss-url
Advanced tools
Comparing version 7.1.0 to 7.1.1
@@ -0,1 +1,5 @@ | ||
# 7.1.0 - 2017-07-24 | ||
Fixed: force wrap url by quotes for `optimizeSvgEncode` ([#105](https://github.com/postcss/postcss-url/issues/105)) | ||
# 7.1.0 - 2017-07-19 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "postcss-url", | ||
"version": "7.1.0", | ||
"version": "7.1.1", | ||
"description": "PostCSS plugin to rebase or inline on url().", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -26,2 +26,4 @@ 'use strict'; | ||
const WITH_QUOTES = /^['"]/; | ||
/** | ||
@@ -124,3 +126,10 @@ * Restricted modes | ||
return newUrl ? `${before}${newUrl}${after}` : matched; | ||
if (!newUrl) return matched; | ||
if (WITH_QUOTES.test(newUrl) && WITH_QUOTES.test(after)) { | ||
before = before.slice(0, -1); | ||
after = after.slice(1); | ||
} | ||
return `${before}${newUrl}${after}`; | ||
}); | ||
@@ -127,0 +136,0 @@ }; |
@@ -19,3 +19,3 @@ 'use strict'; | ||
// | ||
// Lowercase the hex-escapes for better gzipping | ||
return result.replace(/(%[0-9A-Z]{2})/g, (matched, AZ) => { | ||
@@ -34,3 +34,3 @@ return AZ.toLowerCase(); | ||
module.exports = (file, encodeType, shouldOptimizeURIEncode) => { | ||
module.exports = (file, encodeType, shouldOptimizeSvgEncode) => { | ||
const dataMime = `data:${file.mimeType}`; | ||
@@ -48,3 +48,3 @@ | ||
let encodedStr = (shouldOptimizeURIEncode && encodeType === 'encodeURIComponent') | ||
let encodedStr = (shouldOptimizeSvgEncode && encodeType === 'encodeURIComponent') | ||
? optimizedSvgEncode(content) | ||
@@ -51,0 +51,0 @@ : encodeFunc(content); |
@@ -79,5 +79,10 @@ 'use strict'; | ||
const encodedStr = encodeFile(file, encodeType, options.optimizeSvgEncode && isSvg); | ||
const optimizeSvgEncode = isSvg && options.optimizeSvgEncode; | ||
const encodedStr = encodeFile(file, encodeType, optimizeSvgEncode); | ||
const resultValue = options.includeUriFragment && asset.hash | ||
? encodedStr + asset.hash | ||
: encodedStr; | ||
return (options.includeUriFragment && asset.hash) ? encodedStr + asset.hash : encodedStr; | ||
// wrap url by quotes if optimized svg | ||
return optimizeSvgEncode ? `"${resultValue}"` : resultValue; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35688
646