Socket
Socket
Sign inDemoInstall

postcss-normalize-url

Package Overview
Dependencies
5
Maintainers
8
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-normalize-url

Normalize URLs with PostCSS


Version published
Weekly downloads
11M
increased by2.7%
Maintainers
8
Install size
37.4 kB
Created
Weekly downloads
 

Package description

What is postcss-normalize-url?

The postcss-normalize-url npm package is a PostCSS plugin designed to normalize URLs within your CSS. This includes operations such as normalization of quotation marks, removal of default ports, and encoding of special characters in URLs. It helps in reducing the size of your CSS by ensuring URLs are optimized and consistent.

What are postcss-normalize-url's main functionalities?

Normalization of URLs

This feature normalizes URLs by removing the default port (80 for http and 443 for https) and ensures the URL is encoded properly. It also normalizes quotation marks around URLs.

postcss([ require('postcss-normalize-url')() ]).process('a { background-url: url(http://example.com:80/image.png); }').then(result => { console.log(result.css); });

Removal of unnecessary quotes

This feature removes unnecessary quotes around URLs when they are not required, which can help in reducing the size of the CSS file.

postcss([ require('postcss-normalize-url')() ]).process('a { background-url: url("http://example.com/image.png"); }').then(result => { console.log(result.css); });

Encoding of special characters in URLs

This feature ensures that special characters in URLs are properly encoded, making the URL safe to use across different browsers and environments.

postcss([ require('postcss-normalize-url')() ]).process('a { background-url: url(http://example.com/ü.png); }').then(result => { console.log(result.css); });

Other packages similar to postcss-normalize-url

Readme

Source

postcss-normalize-url

Normalize URLs with PostCSS.

Install

With npm do:

npm install postcss-normalize-url --save

Example

Input

h1 {
    background: url("http://site.com:80/image.jpg")
}

Output

h1 {
    background: url(http://site.com/image.jpg)
}

Note that this module will also try to normalize relative URLs, and is capable of stripping unnecessary quotes. For more examples, see the tests.

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

Keywords

FAQs

Last updated on 06 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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