Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
postcss-normalize-url
Advanced tools
Package description
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.
Readme
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 8,706,941 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
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.