diff --git a/lib/less/parser.js b/lib/less/parser.js index 71ab995a..b1a70654 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -526,7 +526,7 @@ less.Parser = function Parser(env) { if (! $(')')) throw new(Error)("missing closing ) for url()"); return new(tree.URL)((value.value || value instanceof tree.Variable) - ? value : new(tree.Anonymous)(value)); + ? value : new(tree.Anonymous)(value), imports.paths); }, // diff --git a/lib/less/tree/url.js b/lib/less/tree/url.js index 03eb954a..62549ead 100644 --- a/lib/less/tree/url.js +++ b/lib/less/tree/url.js @@ -1,6 +1,12 @@ (function (tree) { -tree.URL = function (val) { +tree.URL = function (val, paths) { + // Add the base path if the URL is relative and we are in the browser + if (!/^(?:http:\/)?\//.test(val.value) && + paths.length > 0 && + typeof(window) !== 'undefined') { + val.value = [paths[0], val.value].join('/'); + } this.value = val; }; tree.URL.prototype = {