-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
host path prepended to urls generated with interpolated strings #294
Comments
I ran into the same issue.
produced:
It basically prepended the path to the .less file to make the URL relative when it was intended to be absolute. This was only the case when I ran the compiler in browser and not from the command line. Temporary Fix:
|
@jasonkeene: thanks a bunch for your temporary fix! |
Any idea if this will be fixed any time soon? :) |
Bump! This break string interpolation as documented |
+1 This bug still exists in 1.2.0 when run in the browser. |
+1 This bug still exists in 1.2.1 when run in the browser. |
I'm having the issue in 1.3 as well. Thanks for the temporary fix, @jasonkeene! |
Me too! |
This bug still exists in 1.3 when run in the browser. |
A quick fix in less-1.3.0.js
|
@jasonkeene Just wanted to add my appreciation for providing a temporary solution to this issue: Thanks! |
If this is simply documented better, I'd consider it a feature ;-) |
It's worth pointing out that if you call the less parser on a source this isn't a problem at all. It's only a problem with the "automatic" browser version: |
Thanks soychicka. But is there any solution to fix that as permanently? |
@jasonkeene u just saved some hairs on my head :-) thanks a zillion! |
I don't want to join development or put out a patch, but I do have an explanation and a fix (version 1.3.0). Permanent fix (Non-Minified Source) Line 3013 (function tree.URL): if (typeof(window) !== 'undefined' && !/^(?:https?://|file://|data:|/|@)/.test(val.value) && paths.length > 0) { Explanation: @base-url: "http://assets.fnord.com"; During parsing, url("@{base-url}/images/bg.png") matches as a url and currently gets compared to the regular expression: /^(?:https?://|file://|data:|/)/ "@{base-url}/..." doesn't match (since the variable hasn't been interpolated yet). So its considered a relative path. So it gets turned into: url("http://localhost:3000/path/to/stylesheets/@{base-url}/images/bg.png"). Then variable interpolation takes place, turning it into: url("http://localhost:3000/path/to/stylesheets/http://assets.fnord.com/images/bg.png"); The fix is to include @ as an initial dis-qualifier of relative paths (as I've done in my fix above). I think it will still be interpolated and then re-ran through the tree.URL transform. If the interpolated value is relative, I think it will then be prefixed with the absolute url; if it is absolute, it will be left alone. I hope someone else takes this minor fix and puts the energy in to merge it into the code base. (Cuz I'm too busy to do it). |
How is this closed 8 months ago? I still get localhost refernces after toCSS, but why does LESS do that in the first place? I currently run a script to remove them after compilation, but recently I ran into trouble where I cannot guess what the url is so I cannot remove it... how can I prevent the compiler from outputting absolute urls like that? |
@ayyash http://lesscss.org/#usage look at rootpath and relativeUrls options. post a new issue if something is going wrong |
layer srs is inherited from map srs
In the latest distribution (1.1.3), if you use this paraphrased example from the lesscss.org home page
@base-url: "http://assets.fnord.com";
.thing{
background-image: url("@{base-url}/images/bg.png");
}
the compiled result will be
.thing{
background-image: url("http://localhost:3000/path/to/stylesheets/http://assets.fnord.com/images/bg.png");
}
I don't know if this is a regression, as I've never had chance to use the string interpolation functionality before.
It looks like the string that is tested for the presence of a prefix around line 2270 isn't evaluated first, so the conditional isn't testing against the full url.
I see two possible solutions:
I pulled it off locally - https://gist.github.com/1047106. Still, that's just a temporary fix until I can find out how to do it
The text was updated successfully, but these errors were encountered: