| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/parsmega.nuxt/node_modules/postcss-url/src/lib/ |
Upload File : |
'use strict';
/**
* Optimize encoding SVG files (IE9+, Android 3+)
* @see https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
*
* @param {String} svgContent
* @returns {String}
*/
const optimizedSvgEncode = (svgContent) => {
const result = encodeURIComponent(svgContent)
.replace(/%3D/g, '=')
.replace(/%3A/g, ':')
.replace(/%2F/g, '/')
.replace(/%22/g, "'")
.replace(/%2C/g, ',')
.replace(/%3B/g, ';');
// Lowercase the hex-escapes for better gzipping
return result.replace(/(%[0-9A-Z]{2})/g, (matched, AZ) => {
return AZ.toLowerCase();
});
};
/**
* Encoding file contents to string
*
* @param {PostcssUrl~File} file
* @param {String} [encodeType=base64|encodeURI|encodeURIComponent]
* @param {Boolean} [shouldOptimizeURIEncode]
* @returns {string}
*/
module.exports = (file, encodeType, shouldOptimizeSvgEncode) => {
const dataMime = `data:${file.mimeType}`;
if (encodeType === 'base64') {
return `${dataMime};base64,${file.contents.toString('base64')}`;
}
const encodeFunc = encodeType === 'encodeURI' ? encodeURI : encodeURIComponent;
const content = file.contents.toString('utf8')
// removing new lines
.replace(/\n+/g, '');
let encodedStr = (shouldOptimizeSvgEncode && encodeType === 'encodeURIComponent')
? optimizedSvgEncode(content)
: encodeFunc(content);
encodedStr = encodedStr
.replace(/%20/g, ' ')
.replace(/#/g, '%23');
return `${dataMime},${encodedStr}`;
};