
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
postcss-normalize-url
Advanced tools
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.
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); });
clean-css is a fast and efficient CSS optimizer for Node.js and the browser. It includes functionalities for minifying CSS, which indirectly includes optimizing URLs within stylesheets. However, it is more comprehensive in scope, focusing on overall CSS optimization rather than specifically on URL normalization.
cssnano is a modular CSS minifier that includes various optimizations to reduce the size of CSS files. One of its plugins, postcss-minify-urls, performs tasks similar to postcss-normalize-url by optimizing URLs. cssnano provides a broader range of CSS optimizations, making it a more versatile tool for overall CSS minification.
Normalize URLs with PostCSS.
With npm do:
npm install postcss-normalize-url --save
h1 {
background: url("http://site.com:80/image.jpg")
}
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.
See the PostCSS documentation for examples for your environment.
See CONTRIBUTORS.md.
MIT © Ben Briggs
FAQs
Normalize URLs with PostCSS
The npm package postcss-normalize-url receives a total of 9,602,366 weekly downloads. As such, postcss-normalize-url popularity was classified as popular.
We found that postcss-normalize-url demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
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.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.