Skip to content

Commit

Permalink
fragment urls referencing just a fragment are assumed absolute - refe…
Browse files Browse the repository at this point in the history
…rencing the current page. Fixes #2320
  • Loading branch information
lukeapage committed Feb 2, 2015
1 parent fb5280f commit 2114a3f
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/less/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contexts.Eval.prototype.isMathOn = function () {
};

contexts.Eval.prototype.isPathRelative = function (path) {
return !/^(?:[a-z-]+:|\/)/i.test(path);
return !/^(?:[a-z-]+:|\/|#)/i.test(path);
};

contexts.Eval.prototype.normalizePath = function( path ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/less/environment/abstract-file-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstractFileManager.prototype.alwaysMakePathsAbsolute = function() {
};

abstractFileManager.prototype.isPathAbsolute = function(filename) {
return (/^(?:[a-z-]+:|\/|\\)/i).test(filename);
return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename);
};

abstractFileManager.prototype.join = function(basePath, laterPath) {
Expand Down
1 change: 1 addition & 0 deletions test/browser/css/relative-urls/urls.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}
#misc {
background-image: url(http://localhost:8081/test/browser/less/relative-urls/images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
Expand Down
1 change: 1 addition & 0 deletions test/browser/less/relative-urls/urls.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
#misc {
background-image: url(images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
Expand Down
1 change: 1 addition & 0 deletions test/css/import-interpolation.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ body {
width: 100px;
height: 100px;
background: url('../assets/logo.png');
background: url("#inline-svg");
}

.a {
Expand Down
1 change: 1 addition & 0 deletions test/css/static-urls/urls.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
width: 100px;
height: 100px;
background: url('assets/logo.png');
background: url("#inline-svg");
}
@font-face {
font-family: xecret;
Expand Down
1 change: 1 addition & 0 deletions test/css/urls.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
width: 100px;
height: 100px;
background: url('import/assets/logo.png');
background: url("#inline-svg");
}
@font-face {
font-family: xecret;
Expand Down
1 change: 1 addition & 0 deletions test/less/import/imports/logo.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
width: 100px;
height: 100px;
background: url('../assets/logo.png');
background: url("#inline-svg");
}
2 changes: 1 addition & 1 deletion test/less/urls.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
uri: data-uri('image/jpeg;base64', '../data/image.jpg');
@var: replace('../data/replace.jpg', "replace", "image");
background-image: data-uri(@var), data-uri(replace('../data/image.filext', "filext", "jpg"));

uri-fragment: data-uri('image/jpeg;base64', '../data/image.jpg#fragment');
}

Expand Down

0 comments on commit 2114a3f

Please sign in to comment.