Oliver1
(Oliver)
9 April 2006 19:09
1
Hi,
I have been looking at the documentation and the source of URI.join and
can't see what I have misunderstood.
http://ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI.html#M009245
I except URI.join("http://test.de/test1 ", "test2") in an URI which looks
like http://test.de/test1/test2 and not like http://test.de/test2 . And
from reading the documentation I even expect that
URI.join("http://test.de/ ", "test1", "test2") results in
http://test.de/test1/test2 and not http://test.de/test2
So, that do I misunderstand about the URI class? I am using Ruby
1.8.4 from Darwinports on Mac OS X.
Best regards,
Oliver
···
--
Posted via http://www.ruby-forum.com/ .
That's a strange result. It works as expected for me, also using 1.8.4
via Darwin Ports on OS X:
URI.join("test.de Archiv | Stiftung Warentest , "test2").to_s #=> "test.de Archiv | Stiftung Warentest ;
I don't think you're missing anything: you are getting anomalous
output. Are you testing it with the same input data?
Paul.
···
On 09/04/06, Oliver Andrich <oliver.andrich@gmail.com> wrote:
I except URI.join("test.de Archiv | Stiftung Warentest , "test2") in an URI which looks
like test.de Archiv | Stiftung Warentest and not like test.de Archiv | Stiftung Warentest . And
from reading the documentation I even expect that
URI.join("http://test.de/" , "test1", "test2") results in
test.de Archiv | Stiftung Warentest and not test.de Archiv | Stiftung Warentest
Consider a web browser:
If you are at the site
http://example.com/a
and you click a link whose href is b, its relative and you go to
http://example.com/b
If however the webs server lets you browse directories
and you are at http://example.com/dir/ and you click a link a, you'll end up at
http://example.com/dir/a
URL/URIs aren't quite the same as file paths
···
On Apr 9, 2006, at 6:22 PM, Oliver Andrich wrote:
Can you explain to me why this is correct? I would expect
test.de Archiv | Stiftung Warentest as the result of your call.
Oliver
Think of it this way --
You are in your web-browser on test.de Archiv | Stiftung Warentest . There is a link to "test2":
<a href="test2">test2</a>
Would you expect it to go to test.de Archiv | Stiftung Warentest ? No, it would go to test.de Archiv | Stiftung Warentest .
You want:
URI.join("test.de Archiv | Stiftung Warentest , "test2")
^
URI.join("http://test.de/" , "test1/", "test2")
^
-- Daniel
···
On Apr 10, 2006, at 12:22 AM, Oliver Andrich wrote:
Paul Battley wrote:
URI.join("test.de Archiv | Stiftung Warentest , "test2").to_s #=>
"test.de Archiv | Stiftung Warentest ;
Can you explain to me why this is correct? I would expect
test.de Archiv | Stiftung Warentest as the result of your call.
Can you explain to me why this is correct? I would expect
test.de Archiv | Stiftung Warentest as the result of your call.
Sorry, I misread your original statement, which might make my reply confusing.
You are getting the correct results, as others have said.
It works just like in a browser:
http://example.com/one + two => http://example.com/two
http://example.com/one/ + two => http://example.com/one/two
http://example.com/one + /two => http://example.com/two
http://example.com/one/ + /two => http://example.com/two
Paul.
Oliver1
(Oliver)
10 April 2006 08:12
7
Paul Battley wrote:
Can you explain to me why this is correct? I would expect
test.de Archiv | Stiftung Warentest as the result of your call.
Sorry, I misread your original statement, which might make my reply
confusing.
You are getting the correct results, as others have said.
It works just like in a browser:
http://example.com/one + two => http://example.com/two
http://example.com/one/ + two => http://example.com/one/two
http://example.com/one + /two => http://example.com/two
http://example.com/one/ + /two => http://example.com/two
Thanks Guys,
now I know at least the logic behind URI.join. I am not sure, if it is
the method of choice for my problem, but I have to think about it and
may be I come back with another question.
Oliver
···
--
Posted via http://www.ruby-forum.com/\ .