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
RACK_BASE_URI ignored in url
with string paths
#1535
Comments
If an app mounted to '/app' and has url :test #=> '/app/test'
url 'foo' #=> 'foo'
url 'foo', true, true #=> 'http://10.0.0.10:3000/app/foo'
url '/foo' #=> '/app/foo'
absolute_url :test #=> 'http://10.0.0.10:3000/app/test'
absolute_url 'foo' #=> 'http://10.0.0.10:3000/foo'
absolute_url '/foo' #=> 'http://10.0.0.10:3000/app/foo' If that's right, I have a commit ready. @padrino/core-members any input? |
Thank you! (That is, I assume |
What would be an intuitive thing to return on |
It's probably not worth doing (seems a bit complicated, and you should pretty much always be able to replace relative links to rooted links in your own application), but if you're rendering |
Makes sense to me. I will try it in a while. |
rebase string urls to uri_root, closes #1535
Pursuant to #1532, and related to #1534:
Routing::InstanceMethods#url
completely delegates to Sinatra'surl
for a simple string argument likeurl '/foo'
. However, Sinatra has no concept ofRACK_BASE_URI
, and thus when it is defined generates a wrong URL. As a consequence,url '/foo'
behaviour is inconsistent withurl :foo
.Likely fix:
The quoted code from Routing::ClassMethods#url should be extracted and applied to any URL starting with a slash (i.e.
/foo
), but not on absolute and relative URLs (i.e.http://example.com/foo
orfoo
).Currently this is applied to URLs that are compiled by Padrino, but not to URLs received from Sinatra.
As noted in #1532, there is a workaround for this by using
asset_path
instead, so it is much lower priority than #1534.The text was updated successfully, but these errors were encountered: