Created
June 26, 2011 00:55
-
-
Save soychicka/1047106 to your computer and use it in GitHub Desktop.
Slight improvement on LessCSS's handling of string interpolation in URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// less-1.1.3.js | |
// starting around line 2268 | |
// modify the regex to handle the condition of an interpolated string | |
// /^(?:https?:\/\/|file:\/\/|data:\/\/|@{)?/ | |
// /^(?:https?:\/|file:\/|data:\/)?\// | |
tree.URL = function (val, paths) { | |
if (val.data) { | |
this.attrs = val; | |
} else { | |
// Add the base path if the URL is relative and does not start with an interpolated string and we are in the browser | |
if (!/^(?:https?:\/\/|file:\/\/|data:\/\/|@{)?/.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') { | |
val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value); | |
} | |
this.value = val; | |
this.paths = paths; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment