Socket
Socket
Sign inDemoInstall

postcss-url

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-url - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 6.0.3 - 2017-04-04
Fixed: hash url error
([#89](https://github.com/postcss/postcss-url/issues/89))
# 6.0.2 - 2017-04-04

@@ -2,0 +6,0 @@ Fixed: match options before analyzing

2

package.json
{
"name": "postcss-url",
"version": "6.0.2",
"version": "6.0.3",
"description": "PostCSS plugin to rebase or inline on url().",

@@ -5,0 +5,0 @@ "keywords": [

@@ -64,9 +64,11 @@ 'use strict';

const replaceUrl = (url, dir, options, result, decl) => {
const asset = prepareAsset(url, dir, options.basePath);
const asset = prepareAsset(url, dir, decl);
const relativeToRoot = path.relative(process.cwd(), asset.absolutePath);
const matchedOptions = matchOptions(relativeToRoot, options);
if (!matchedOptions) return;
const isFunction = typeof matchedOptions.url === 'function';
if (!isFunction && isUrlShouldBeIgnored(url, matchedOptions)) return;

@@ -118,3 +120,3 @@

});
}
};
});

@@ -121,0 +123,0 @@

@@ -19,12 +19,8 @@ 'use strict';

/**
* Check if url is absolute, hash or data-uri
*
* @param {String} assetUrl
* @param {PostcssUrl~Options} options
* @returns {Boolean}
*/
const isUrlShouldBeIgnored = (assetUrl, options) => {
const isUrlWithoutPathname = (assetUrl) => {
return assetUrl[0] === '#'
|| assetUrl.indexOf('%23') === 0
|| (assetUrl[0] === '/' && !options.basePath)
|| assetUrl.indexOf('data:') === 0

@@ -35,2 +31,13 @@ || /^[a-z]+:\/\//.test(assetUrl);

/**
* Check if url is absolute, hash or data-uri
*
* @param {String} assetUrl
* @param {PostcssUrl~Options} options
* @returns {Boolean}
*/
const isUrlShouldBeIgnored = (assetUrl, options) => {
return isUrlWithoutPathname(assetUrl) || (assetUrl[0] === '/' && !options.basePath);
};
/**
* @param {String} baseDir - absolute target path

@@ -54,2 +61,11 @@ * @param {String} assetsPath - extend asset path, can be absolute path

/**
* Stylesheet file path from decl
*
* @param {Decl} decl
* @returns {String}
*/
const getPathDeclFile = (decl) =>
decl.source && decl.source.input && decl.source.input.file;
/**
* Stylesheet file dir from decl

@@ -61,3 +77,3 @@ *

const getDirDeclFile = (decl) => {
const filename = decl.source && decl.source.input && decl.source.input.file;
const filename = getPathDeclFile(decl);

@@ -92,7 +108,11 @@ return filename ? path.dirname(filename) : process.cwd();

* @param {PostcssUrl~Dir} dir
* @param {Decl} decl
* @returns {PostcssUrl~Asset}
*/
const prepareAsset = (assetUrl, dir) => {
const prepareAsset = (assetUrl, dir, decl) => {
const parsedUrl = url.parse(assetUrl);
const absolutePath = path.join(dir.file, parsedUrl.pathname);
const pathname = !isUrlWithoutPathname(assetUrl) ? parsedUrl.pathname : null;
const absolutePath = pathname
? path.join(dir.file, pathname)
: getPathDeclFile(decl);

@@ -114,2 +134,3 @@ return {

getDirDeclFile,
getPathDeclFile,
getTargetDir,

@@ -116,0 +137,0 @@ getPathByBasePath,

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