🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-normalize-url

Package Overview
Dependencies
Maintainers
5
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-normalize-url - npm Package Compare versions

Comparing version

to
4.0.0

50

dist/index.js

@@ -29,9 +29,19 @@ 'use strict';

var multiline = /\\[\r\n]/;
var escapeChars = /([\s\(\)"'])/g;
const multiline = /\\[\r\n]/;
const escapeChars = /([\s\(\)"'])/g;
function convert(url, options) {
if ((0, _isAbsoluteUrl2.default)(url) || !url.indexOf('//')) {
return (0, _normalizeUrl2.default)(url, options);
if ((0, _isAbsoluteUrl2.default)(url) || url.startsWith('//')) {
let normalizedURL = null;
try {
normalizedURL = (0, _normalizeUrl2.default)(url, options);
} catch (e) {
normalizedURL = url;
}
return normalizedURL;
}
// `path.normalize` always returns backslashes on Windows, need replace in `/`
return _path2.default.normalize(url).replace(new RegExp('\\' + _path2.default.sep, 'g'), '/');

@@ -41,4 +51,4 @@ }

function transformNamespace(rule) {
rule.params = (0, _postcssValueParser2.default)(rule.params).walk(function (node) {
if (node.type === 'function' && node.value === 'url' && node.nodes.length) {
rule.params = (0, _postcssValueParser2.default)(rule.params).walk(node => {
if (node.type === 'function' && node.value.toLowerCase() === 'url' && node.nodes.length) {
node.type = 'string';

@@ -56,9 +66,9 @@ node.quote = node.nodes[0].quote || '"';

function transformDecl(decl, opts) {
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) {
if (node.type !== 'function' || node.value !== 'url' || !node.nodes.length) {
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(node => {
if (node.type !== 'function' || node.value.toLowerCase() !== 'url' || !node.nodes.length) {
return false;
}
var url = node.nodes[0];
var escaped = void 0;
let url = node.nodes[0];
let escaped;

@@ -68,7 +78,15 @@ node.before = node.after = '';

if (~url.value.indexOf('data:image/') || ~url.value.indexOf('data:application/') || ~url.value.indexOf('data:font/')) {
// Skip empty URLs
// Empty URL function equals request to current stylesheet where it is declared
if (url.value.length === 0) {
url.quote = '';
return false;
}
if (!~url.value.indexOf('chrome-extension')) {
if (/^data:(.*)?,/.test(url.value)) {
return false;
}
if (!/^.+-extension:\//i.test(url.value)) {
url.value = convert(url.value, opts);

@@ -91,3 +109,3 @@ }

exports.default = _postcss2.default.plugin('postcss-normalize-url', function (opts) {
exports.default = _postcss2.default.plugin('postcss-normalize-url', opts => {
opts = Object.assign({}, {

@@ -99,7 +117,7 @@ normalizeProtocol: false,

return function (css) {
css.walk(function (node) {
return css => {
css.walk(node => {
if (node.type === 'decl') {
return transformDecl(node, opts);
} else if (node.type === 'atrule' && node.name === 'namespace') {
} else if (node.type === 'atrule' && node.name.toLowerCase() === 'namespace') {
return transformNamespace(node);

@@ -106,0 +124,0 @@ }

{
"name": "postcss-normalize-url",
"version": "4.0.0-rc.2",
"version": "4.0.0",
"description": "Normalize URLs with PostCSS",

@@ -25,3 +25,3 @@ "main": "dist/index.js",

"is-absolute-url": "^2.0.0",
"normalize-url": "^1.0.0",
"normalize-url": "^3.0.0",
"postcss": "^6.0.0",

@@ -32,5 +32,5 @@ "postcss-value-parser": "^3.0.0"

"babel-cli": "^6.0.0",
"cross-env": "^3.0.0"
"cross-env": "^5.0.0"
},
"homepage": "https://github.com/ben-eb/cssnano",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -41,9 +41,9 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/cssnano",
"repository": "cssnano/cssnano",
"bugs": {
"url": "https://github.com/ben-eb/cssnano/issues"
"url": "https://github.com/cssnano/cssnano/issues"
},
"engines": {
"node": ">=4"
"node": ">=6.9.0"
}
}

@@ -48,3 +48,3 @@ # [postcss][postcss]-normalize-url

See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md).
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).

@@ -51,0 +51,0 @@ ## License