From afd983b9ea24cdcac035a759b7dd7c57e2e8fc71 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 16 Jul 2010 14:20:58 +0800 Subject: [PATCH] Fixed dot in css name error(when using style.1.css and style.2.css), also fixed 'url()' error --- lib/less/browser.js | 11 ++++++----- lib/less/parser.js | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) 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)