Socket
Socket
Sign inDemoInstall

postcss-normalize-url

Package Overview
Dependencies
5
Maintainers
8
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.0 to 6.0.0

src/normalize.js

8

package.json
{
"name": "postcss-normalize-url",
"version": "5.1.0",
"version": "6.0.0",
"description": "Normalize URLs with PostCSS",

@@ -23,3 +23,2 @@ "main": "src/index.js",

"dependencies": {
"normalize-url": "^6.0.1",
"postcss-value-parser": "^4.2.0"

@@ -38,3 +37,3 @@ },

"engines": {
"node": "^10 || ^12 || >=14.0"
"node": "^14 || ^16 || >=18.0"
},

@@ -46,4 +45,3 @@ "devDependencies": {

"postcss": "^8.2.15"
},
"readme": "# [postcss][postcss]-normalize-url\n\n> [Normalize URLs](https://github.com/sindresorhus/normalize-url) with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-normalize-url) do:\n\n```\nnpm install postcss-normalize-url --save\n```\n\n## Example\n\n### Input\n\n```css\nh1 {\n background: url(\"http://site.com:80/image.jpg\")\n}\n```\n\n### Output\n\n```css\nh1 {\n background: url(http://site.com/image.jpg)\n}\n```\n\nNote that this module will also try to normalize relative URLs, and is capable\nof stripping unnecessary quotes. For more examples, see the [tests](test.js).\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## API\n\n### normalize([options])\n\nPlease see the [normalize-url documentation][docs]. By default,\n`normalizeProtocol`, `stripHash` & `stripWWW` are set to `false`.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[docs]: https://github.com/sindresorhus/normalize-url#options\n[postcss]: https://github.com/postcss/postcss\n"
}
}

@@ -39,9 +39,2 @@ # [postcss][postcss]-normalize-url

## API
### normalize([options])
Please see the [normalize-url documentation][docs]. By default,
`normalizeProtocol`, `stripHash` & `stripWWW` are set to `false`.
## Contributors

@@ -48,0 +41,0 @@

'use strict';
const path = require('path');
const valueParser = require('postcss-value-parser');
const normalize = require('normalize-url');
const normalize = require('./normalize.js');

@@ -30,6 +30,5 @@ const multiline = /\\[\r\n]/;

* @param {string} url
* @param {normalize.Options} options
* @return {string}
*/
function convert(url, options) {
function convert(url) {
if (isAbsolute(url) || url.startsWith('//')) {

@@ -39,3 +38,3 @@ let normalizedURL;

try {
normalizedURL = normalize(url, options);
normalizedURL = normalize(url);
} catch (e) {

@@ -79,6 +78,5 @@ normalizedURL = url;

* @param {import('postcss').Declaration} decl
* @param {normalize.Options} opts
* @return {void}
*/
function transformDecl(decl, opts) {
function transformDecl(decl) {
decl.value = valueParser(decl.value)

@@ -113,3 +111,3 @@ .walk((node) => {

if (!/^.+-extension:\//i.test(url.value)) {
url.value = convert(url.value, opts);
url.value = convert(url.value);
}

@@ -133,21 +131,7 @@

/** @typedef {normalize.Options} Options */
/**
* @type {import('postcss').PluginCreator<Options>}
* @param {Options} opts
* @type {import('postcss').PluginCreator<void>}
* @return {import('postcss').Plugin}
*/
function pluginCreator(opts) {
opts = Object.assign(
{},
{
normalizeProtocol: false,
sortQueryParameters: false,
stripHash: false,
stripWWW: false,
stripTextFragment: false,
},
opts
);
function pluginCreator() {
return {

@@ -159,3 +143,3 @@ postcssPlugin: 'postcss-normalize-url',

if (node.type === 'decl') {
return transformDecl(node, opts);
return transformDecl(node);
} else if (

@@ -162,0 +146,0 @@ node.type === 'atrule' &&

export = pluginCreator;
/** @typedef {normalize.Options} Options */
/**
* @type {import('postcss').PluginCreator<Options>}
* @param {Options} opts
* @type {import('postcss').PluginCreator<void>}
* @return {import('postcss').Plugin}
*/
declare function pluginCreator(opts: Options): import('postcss').Plugin;
declare function pluginCreator(): import('postcss').Plugin;
declare namespace pluginCreator {
export { postcss, Options };
const postcss: true;
}
type Options = normalize.Options;
declare var postcss: true;
import normalize = require("normalize-url");
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