grunt-packer
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -1,9 +0,16 @@ | ||
var path = require('path'), | ||
helpers = require('./helpers.js'), | ||
fs = require('fs'), | ||
async = require('async'), | ||
postcss = require('postcss'); | ||
var | ||
path = require('path'), | ||
helpers = require('./helpers.js'), | ||
fs = require('fs'), | ||
async = require('async'), | ||
postcss = require('postcss'); | ||
var | ||
validUrls = /url\((?!("|')?(\/|#|data:|[a-z]+:\/\/))[^)]+\)/ig, | ||
urlPath = /url\((?:"|'|\s)?([^"'\s]+?)(?:"|'|\s)?\)/i, | ||
importCss = /@import[^;]+;/ig, | ||
dblSlashes = /\\/g; | ||
function resolveUrl(root, code, cssDir) { | ||
var matchResult = code.match(/url\((?!("|')?data:)[^#\)]+?\)/ig); | ||
var matchResult = code.match(validUrls); | ||
@@ -15,9 +22,9 @@ root = path.normalize(root + path.sep); | ||
matchResult.forEach(function(match){ | ||
var parts = match.match(/url\((?:"|'|\s)?([^"'\s]+?)(?:"|'|\s)?\)/i); | ||
var parts = match.match(urlPath); | ||
if(parts) { | ||
var url; | ||
if(parts[1].charAt(0) == '/') | ||
if(parts[1].charAt(0) == '/') { | ||
url = parts[1]; | ||
else { | ||
} else { | ||
var newPath = path.resolve(cssDir, parts[1]); | ||
@@ -29,3 +36,3 @@ url = path.relative(root, newPath); | ||
} | ||
code = code.replace(match, "url('" + url.replace(/\\/g, '/') + "')"); | ||
code = code.replace(match, "url('" + url.replace(dblSlashes, '/') + "')"); | ||
} | ||
@@ -38,3 +45,3 @@ }); | ||
function bumpImportsUp(packedCss) { | ||
var imports = packedCss.match(/@import[^;]+;/ig); | ||
var imports = packedCss.match(importCss); | ||
if (imports) { | ||
@@ -158,3 +165,3 @@ imports.forEach(function(anImport){ | ||
rel: 'stylesheet', | ||
href: '/' + path.replace(/\\/g, '/') | ||
href: '/' + path.replace(dblSlashes, '/') | ||
}); | ||
@@ -161,0 +168,0 @@ } |
{ | ||
"name": "grunt-packer", | ||
"description": "Grunt plugin to automagically concat JS and CSS files found in HTML", | ||
"version": "0.3.3", | ||
"author": "Oleg Elifantiev <oleg@elifantiev.ru>", | ||
"version": "0.3.4", | ||
"author": { | ||
"name": "Oleg Elifantiev", | ||
"email": "oleg@elifantiev.ru" | ||
}, | ||
"contributors": [], | ||
@@ -10,3 +13,3 @@ "main": "index.js", | ||
"repository": { | ||
"url": "https://github.com/Olegas/grunt-packer.git", | ||
"url": "git+https://github.com/Olegas/grunt-packer.git", | ||
"type": "git" | ||
@@ -13,0 +16,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1037021
63
18613
1