diff --git a/lib/less/browser.js b/lib/less/browser.js index 310e5ce7..db6d77e6 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -146,11 +146,12 @@ function loadStyleSheet(sheet, callback, reload, remaining) { } function extractId(href) { - return href.replace(/^[a-z]+:\/\/?[^\/]+/, '') // Remove protocol & domain - .replace(/^\//, '') // Remove root / - .replace(/\?.*$/, '') // Remove query - .replace(/\.[^\/]+$/, '') // Remove file extension - .replace(/[^\w-]+/g, '-'); // Replace illegal characters + return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain + .replace(/^\//, '' ) // Remove root / + .replace(/\?.*$/, '' ) // Remove query + .replace(/\.[^\.\/]+$/, '' ) // Remove file extension + .replace(/[^\.\w-]+/g, '-') // Replace illegal characters + .replace(/\./g, ':'); // Replace dots with colons(for valid id) } function createCSS(styles, sheet, lastModified) { diff --git a/lib/less/parser.js b/lib/less/parser.js index e226285a..71ab995a 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -522,7 +522,7 @@ less.Parser = function Parser(env) { var value; if (input.charAt(i) !== 'u' || !$(/^url\(/)) return; - value = $(this.entities.quoted) || $(this.entities.variable) || $(/^[-\w%@$\/.&=:;#+?]+/); + value = $(this.entities.quoted) || $(this.entities.variable) || $(/^[-\w%@$\/.&=:;#+?]+/) || ""; if (! $(')')) throw new(Error)("missing closing ) for url()"); return new(tree.URL)((value.value || value instanceof tree.Variable)