Socket
Socket
Sign inDemoInstall

css-url-rewriter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-url-rewriter

Looks for `url(...)` definitions in CSS and rewrites them


Version published
Weekly downloads
971
increased by25.61%
Maintainers
1
Weekly downloads
 
Created
Source

css-url-rewriter Build Status

NPM

Simple function that looks for url(...) definitions in a string of CSS and runs them through your own rewriter function.

Getting Started

Install the module with: npm install css-url-rewriter

var rewriteCSSURLs = require('css-url-rewriter');

// example - add a query string to all URLs
var newCSS = rewriteCSSURLs(someCSS, function (url) {
  return url + '?12345';
});

It will process all URLs it encounters by default, even data: URIs, so you need to check for those manually if you want to handle them differently. The only exception is URLs in 'excluded properties' (see settings).

Settings

You can optionally pass in a settings object as a second argument:

var newCSS = rewriteCSSURLs(someCSS, settings, function (url) {
  return url + '?12345';
});

Currently there is only one configurable setting, excludedProperties, which is an array of properties that you want to skip. This setting defaults to ['behavior', '*behavior'] (because you usually don't want to mess with URLs in this proprietary MSIE property, because it has weird relativity rules).

License

Copyright (c) 2014 Callum Locke. Licensed under the MIT license.

FAQs

Package last updated on 17 Oct 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc