Skip to content

Commit

Permalink
Handle ./ paths in the browser when relative correctly. Fixes less#1238
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Apr 30, 2013
1 parent 5d102d5 commit 46e1613
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/less/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ function extractUrlParts(url, baseUrl) {
if (urlParts[3]) {
directories = urlParts[3].replace("\\", "/").split("/");

// extract out . before .. so .. doesn't absorb a non-directory
for(i = 0; i < directories.length; i++) {
if (directories[i] === ".") {
directories.splice(i, 1);
i -= 1;
}
}

for(i = 0; i < directories.length; i++) {
if (directories[i] === ".." && i > 0) {
directories.splice(i-1, 2);
Expand Down
2 changes: 1 addition & 1 deletion test/browser/less/relative-urls/urls.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "../imports/urls.less";
@import ".././imports/urls.less";
@import "http://localhost:8081/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
Expand Down

0 comments on commit 46e1613

Please sign in to comment.