
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
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 11,092,577 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.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.