combohandler
Advanced tools
Comparing version 0.3.2 to 0.3.3
Combo Handler History | ||
===================== | ||
0.3.3 (2013-04-26) | ||
------------------ | ||
* Fixed a naive regular expression that was preventing url() rewriting when | ||
background property shorthand syntax was used. | ||
0.3.2 (2013-04-26) | ||
@@ -5,0 +11,0 @@ ------------------ |
@@ -7,13 +7,10 @@ /** | ||
var URI = require("URIjs"); | ||
var memoize = require('../utils').memoize; | ||
var RX_URL = /:\s*url\(\s*(['"]?)(\S+)\1\s*\)/g; | ||
var RX_URL = /(?:\@import)?\s*url\(\s*(['"]?)(\S+)\1\s*\)/g; | ||
var RX_IMPORT = /\@import\s*(?:url\(\s*)?(['"]?)(\S+)\1(?:\s*\))?[^;'"]*;/g; | ||
var replacer = function replacer(basePath, relativePath) { | ||
var replacer = function replacer(basePath, relativePath, importsEnabled) { | ||
return function (substr, quote, match) { | ||
// There is a ton of complexity related to URL parsing related | ||
// to unicode, escapement, etc. Rather than try to capture that, | ||
// this just does a simple sniff to validate whether the URL | ||
// needs to be rewritten. | ||
if (!URI(match).is("relative")) { | ||
if (!substringEligible(substr, match, importsEnabled)) { | ||
return substr; | ||
@@ -30,2 +27,16 @@ } | ||
var substringEligible = memoize(function (substr, match, importsEnabled) { | ||
// There is a ton of complexity related to URL parsing related | ||
// to unicode, escapement, etc. Rather than try to capture that, | ||
// this just does a simple sniff to validate whether the URL | ||
// needs to be rewritten. | ||
var enabled = URI(match).is("relative"); | ||
if (enabled && substr.indexOf('@import') > -1) { | ||
enabled = importsEnabled; | ||
} | ||
return enabled; | ||
}); | ||
/** | ||
@@ -89,3 +100,3 @@ Route middleware that rewrites relative paths found in CSS source | ||
var replaceCallback = replacer(basePath, relativePath); | ||
var replaceCallback = replacer(basePath, relativePath, importsEnabled); | ||
@@ -92,0 +103,0 @@ if (importsEnabled) { |
@@ -7,2 +7,3 @@ /** | ||
exports.merge = merge; | ||
exports.memoize = memoize; | ||
@@ -28,1 +29,15 @@ function mix(receiver, supplier) { | ||
} | ||
function memoize(source) { | ||
var cache = {}; | ||
return function () { | ||
var key = [].join.call(arguments, '__'); | ||
if (!(key in cache)) { | ||
cache[key] = source.apply(source, arguments); | ||
} | ||
return cache[key]; | ||
}; | ||
} |
{ | ||
"name" : "combohandler", | ||
"description": "Simple Yahoo!-style combo handler.", | ||
"version" : "0.3.2", | ||
"version" : "0.3.3", | ||
"keywords" : [ | ||
@@ -6,0 +6,0 @@ "combo", "combohandler", "combohandle", "combine", "cdn", "css", "yui" |
@@ -316,2 +316,3 @@ /*global describe, before, after, it */ | ||
var TEMPLATE_URLS = [ | ||
"#shorthand { background: transparent left top no-repeat url(__PATH__shorthand.png);}", | ||
"#no-quotes { background: url(__PATH__no-quotes.png);}", | ||
@@ -318,0 +319,0 @@ "#single-quotes { background: url(\'__PATH__single-quotes.png\');}", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125114
2520