Socket
Socket
Sign inDemoInstall

postcss-normalize-url

Package Overview
Dependencies
7
Maintainers
8
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1 to 5.0.0-rc.0

107

CHANGELOG.md

@@ -1,109 +0,32 @@

# 4.0.0-rc.0
# Change Log
* Breaking: Drops support for Node 0.12, we now require at least Node 4.
* Breaking: Update PostCSS to 6.0.0.
* Breaking: `stripWWW` is now set to `false` by default.
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# 3.0.8
# 5.0.0-rc.0 (2021-02-19)
* Fixes `@namespace` URL conversion; now the semantics of the URL are preserved
and only the `url(foo)` to `"foo"` optimisation is performed.
# 3.0.7
### chore
* Fix `main` field in `package.json`.
* minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
# 3.0.6
* Now compiled with Babel 6.
### Features
# 3.0.5
* migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
* Fixes an issue where base64 encoded OpenType font urls were being erroneously
converted by the module (thanks to @ln-e).
# 3.0.4
### BREAKING CHANGES
* Fixes incorrect minification of empty non-url functions.
* minimum supported `postcss` version is `8.2.1`
* minimum require version of node is 10.13
# 3.0.3
* Updates postcss-value-parser to version 3 (thanks to @TrySound).
# 3.0.2
## 4.1.1 (2018-09-24)
* Fixes incorrect minification of chrome-extension urls.
# 3.0.1
### Bug Fixes
* Bump postcss-value-parser to `2.0.2`.
# 3.0.0
* Upgraded to PostCSS 5.
# 2.1.3
* Replaces trim space nodes function with a built in method
of postcss-value-parser.
# 2.1.2
* postcss-normalize-url now uses postcss-value-parser to iterate
url values (thanks to @TrySound).
* Fixed `@namespace` URL reduction behaviour. (thanks to @TrySound).
# 2.1.1
* Increased performance by using a single call to `eachInside` rather than two.
# 2.1.0
* Adds `keepWWW` option.
* Compatibility fixes for `is-absolute-url@2.0.0`.
# 2.0.3
* Fixes an issue where embedded base 64 data was being converted as if it were
a URL.
# 2.0.2
* Addresses an issue where relative path separators were converted to
backslashes on Windows.
# 2.0.1
* Documentation/metadata tweaks for plugin guidelines compatibility.
* Bump css-list to 0.1.0, use instead of postcss.list.space for namespace
rule normalization.
# 2.0.0
* Improved URL detection when using two or more in the same declaration.
* node 0.10 is no longer supported.
# 1.2.1
* Patch to address incorrect transformation of `@document` rules.
# 1.2.0
* Fixes an issue where options could not be passed through.
* Support for normalising URLs in `@namespace` rules.
# 1.1.0
* Now uses the PostCSS `4.1` plugin API.
# 1.0.2
* Adds a JSHint config, code tidied up.
# 1.0.1
* Bug fix; does not transform embedded base 64 or svg images.
# 1.0.0
* Initial release.
* do not handle uppercase data URI in url function ([#608](https://github.com/cssnano/cssnano/issues/608)) ([c43be8d](https://github.com/cssnano/cssnano/commit/c43be8d62b4c03b33390b177ff8e338b7192d824))
* **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)

181

dist/index.js

@@ -1,122 +0,125 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = void 0;
var _path = require('path');
var _path = _interopRequireDefault(require("path"));
var _path2 = _interopRequireDefault(_path);
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
var _postcss = require('postcss');
var _normalizeUrl = _interopRequireDefault(require("normalize-url"));
var _postcss2 = _interopRequireDefault(_postcss);
var _isAbsoluteUrl = _interopRequireDefault(require("is-absolute-url"));
var _postcssValueParser = require('postcss-value-parser');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
const multiline = /\\[\r\n]/; // eslint-disable-next-line no-useless-escape
var _normalizeUrl = require('normalize-url');
const escapeChars = /([\s\(\)"'])/g;
var _normalizeUrl2 = _interopRequireDefault(_normalizeUrl);
function convert(url, options) {
if ((0, _isAbsoluteUrl.default)(url) || url.startsWith('//')) {
let normalizedURL = null;
var _isAbsoluteUrl = require('is-absolute-url');
try {
normalizedURL = (0, _normalizeUrl.default)(url, options);
} catch (e) {
normalizedURL = url;
}
var _isAbsoluteUrl2 = _interopRequireDefault(_isAbsoluteUrl);
return normalizedURL;
} // `path.normalize` always returns backslashes on Windows, need replace in `/`
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const multiline = /\\[\r\n]/;
const escapeChars = /([\s\(\)"'])/g;
return _path.default.normalize(url).replace(new RegExp('\\' + _path.default.sep, 'g'), '/');
}
function convert(url, options) {
if ((0, _isAbsoluteUrl2.default)(url) || url.startsWith('//')) {
let normalizedURL = null;
function transformNamespace(rule) {
rule.params = (0, _postcssValueParser.default)(rule.params).walk(node => {
if (node.type === 'function' && node.value.toLowerCase() === 'url' && node.nodes.length) {
node.type = 'string';
node.quote = node.nodes[0].quote || '"';
node.value = node.nodes[0].value;
}
try {
normalizedURL = (0, _normalizeUrl2.default)(url, options);
} catch (e) {
normalizedURL = url;
}
return normalizedURL;
if (node.type === 'string') {
node.value = node.value.trim();
}
// `path.normalize` always returns backslashes on Windows, need replace in `/`
return _path2.default.normalize(url).replace(new RegExp('\\' + _path2.default.sep, 'g'), '/');
return false;
}).toString();
}
function transformNamespace(rule) {
rule.params = (0, _postcssValueParser2.default)(rule.params).walk(node => {
if (node.type === 'function' && node.value.toLowerCase() === 'url' && node.nodes.length) {
node.type = 'string';
node.quote = node.nodes[0].quote || '"';
node.value = node.nodes[0].value;
}
if (node.type === 'string') {
node.value = node.value.trim();
}
return false;
}).toString();
}
function transformDecl(decl, opts) {
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(node => {
if (node.type !== 'function' || node.value.toLowerCase() !== 'url' || !node.nodes.length) {
return false;
}
decl.value = (0, _postcssValueParser.default)(decl.value).walk(node => {
if (node.type !== 'function' || node.value.toLowerCase() !== 'url') {
return false;
}
let url = node.nodes[0];
let escaped;
node.before = node.after = '';
node.before = node.after = '';
url.value = url.value.trim().replace(multiline, '');
if (!node.nodes.length) {
return false;
}
// Skip empty URLs
// Empty URL function equals request to current stylesheet where it is declared
if (url.value.length === 0) {
url.quote = '';
let url = node.nodes[0];
let escaped;
url.value = url.value.trim().replace(multiline, ''); // Skip empty URLs
// Empty URL function equals request to current stylesheet where it is declared
return false;
}
if (url.value.length === 0) {
url.quote = '';
return false;
}
if (/^data:(.*)?,/i.test(url.value)) {
return false;
}
if (/^data:(.*)?,/i.test(url.value)) {
return false;
}
if (!/^.+-extension:\//i.test(url.value)) {
url.value = convert(url.value, opts);
}
if (!/^.+-extension:\//i.test(url.value)) {
url.value = convert(url.value, opts);
}
if (escapeChars.test(url.value) && url.type === 'string') {
escaped = url.value.replace(escapeChars, '\\$1');
if (escaped.length < url.value.length + 2) {
url.value = escaped;
url.type = 'word';
}
} else {
url.type = 'word';
if (escapeChars.test(url.value) && url.type === 'string') {
escaped = url.value.replace(escapeChars, '\\$1');
if (escaped.length < url.value.length + 2) {
url.value = escaped;
url.type = 'word';
}
} else {
url.type = 'word';
}
return false;
}).toString();
}
function pluginCreator(opts) {
opts = Object.assign({}, {
normalizeProtocol: false,
stripHash: false,
stripWWW: false
}, opts);
return {
postcssPlugin: 'postcss-normalize-url',
OnceExit(css) {
css.walk(node => {
if (node.type === 'decl') {
return transformDecl(node, opts);
} else if (node.type === 'atrule' && node.name.toLowerCase() === 'namespace') {
return transformNamespace(node);
}
});
}
return false;
}).toString();
};
}
exports.default = _postcss2.default.plugin('postcss-normalize-url', opts => {
opts = Object.assign({}, {
normalizeProtocol: false,
stripFragment: false,
stripWWW: false
}, opts);
return css => {
css.walk(node => {
if (node.type === 'decl') {
return transformDecl(node, opts);
} else if (node.type === 'atrule' && node.name.toLowerCase() === 'namespace') {
return transformNamespace(node);
}
});
};
});
module.exports = exports['default'];
pluginCreator.postcss = true;
var _default = pluginCreator;
exports.default = _default;
module.exports = exports.default;
{
"name": "postcss-normalize-url",
"version": "4.0.1",
"version": "5.0.0-rc.0",
"description": "Normalize URLs with PostCSS",

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

"scripts": {
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/"
"prebuild": "del-cli dist",
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
"prepublish": "yarn build"
},

@@ -25,11 +27,6 @@ "keywords": [

"dependencies": {
"is-absolute-url": "^2.0.0",
"normalize-url": "^3.0.0",
"postcss": "^7.0.0",
"postcss-value-parser": "^3.0.0"
"is-absolute-url": "^3.0.3",
"normalize-url": "^4.5.0",
"postcss-value-parser": "^4.1.0"
},
"devDependencies": {
"babel-cli": "^6.0.0",
"cross-env": "^5.0.0"
},
"homepage": "https://github.com/cssnano/cssnano",

@@ -46,4 +43,11 @@ "author": {

"engines": {
"node": ">=6.9.0"
}
"node": "^10 || ^12 || >=14.0"
},
"devDependencies": {
"postcss": "^8.2.1"
},
"peerDependencies": {
"postcss": "^8.2.1"
},
"gitHead": "8c16e67a4d24a13ac7e09a36d4faf504196efd0f"
}

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

Please see the [normalize-url documentation][docs]. By default,
`normalizeProtocol`, `stripFragment` & `stripWWW` are set to `false`.
`normalizeProtocol`, `stripHash` & `stripWWW` are set to `false`.

@@ -47,0 +47,0 @@ ## Contributors

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc