mirror of
https://github.com/less/less.js.git
synced 2026-04-09 03:00:20 -04:00
Merge branch 'normalized-urls' of https://github.com/rjgotten/less.js into 1.5.0-wip
Conflicts: test/css/static-urls/urls.css test/css/urls.css
This commit is contained in:
@@ -87,6 +87,33 @@
|
||||
return !/^(?:[a-z-]+:|\/)/.test(path);
|
||||
};
|
||||
|
||||
tree.evalEnv.prototype.normalizePath = function( path ) {
|
||||
var
|
||||
segments = path.split("/").reverse(),
|
||||
segment;
|
||||
|
||||
path = [];
|
||||
while (segments.length !== 0 ) {
|
||||
segment = segments.pop();
|
||||
switch( segment ) {
|
||||
case ".":
|
||||
break;
|
||||
case "..":
|
||||
if ((path.length === 0) || (path[path.length - 1] === "..")) {
|
||||
path.push( segment );
|
||||
} else {
|
||||
path.pop();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
path.push( segment );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path.join("/");
|
||||
};
|
||||
|
||||
//todo - do the same for the toCSS env
|
||||
//tree.toCSSEnv = function (options) {
|
||||
//};
|
||||
|
||||
@@ -73,13 +73,18 @@ tree.Import.prototype = {
|
||||
evalPath: function (env) {
|
||||
var path = this.path.eval(env);
|
||||
var rootpath = this.currentFileInfo && this.currentFileInfo.rootpath;
|
||||
if (rootpath && !(path instanceof tree.URL)) {
|
||||
var pathValue = path.value;
|
||||
// Add the base path if the import is relative
|
||||
if (pathValue && env.isPathRelative(pathValue)) {
|
||||
path.value = rootpath + pathValue;
|
||||
|
||||
if (!(path instanceof tree.URL)) {
|
||||
if (rootpath) {
|
||||
var pathValue = path.value;
|
||||
// Add the base path if the import is relative
|
||||
if (pathValue && env.isPathRelative(pathValue)) {
|
||||
path.value = rootpath + pathValue;
|
||||
}
|
||||
}
|
||||
path.value = env.normalizePath(path.value);
|
||||
}
|
||||
|
||||
return path;
|
||||
},
|
||||
eval: function (env) {
|
||||
|
||||
@@ -27,6 +27,8 @@ tree.URL.prototype = {
|
||||
val.value = rootpath + val.value;
|
||||
}
|
||||
|
||||
val.value = ctx.normalizePath(val.value);
|
||||
|
||||
return new(tree.URL)(val, null);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user