Hello all,
I am trying to track down a problem with (my use of) BUrl objects and
I
am getting a bit stuck in the BUrl source code.
I have the following small test case:
// Standard C headers
#include <stdio.h>
// Haiku headers
#include <support/Url.h>
int main(int argc, char **argv) {
BUrl base("http://www.example.com/test/example.html";);
BUrl test1(base, "../index.html");
BString urlString = test1.UrlString();
printf("Test 1 url:%s\n", urlString.String());
BUrl test2(base, "index.html");
urlString = test2.UrlString();
printf("Test 2 url:%s\n", urlString.String());
return 0;
}
I am expecting the "Test 1 url" to print "http://www.example.com/index.html" ;
and the "Test 2 url" to print "http://www.example.com/test/index.html", ;(expected
but they both print "http://www.example.com/test/index.html" ;
output of "Test 2 url"). Is this expectation wrong?
I looked at the source code of BUrl to see where this is going wrong
and it seems that at the point where a BUrl is constructed, the ".."
part is lost. This seems to happen in _ExplodeUrlString. It tries to
determine if it starts with a protocol and I cannot follow the logic
of
that check (function explode_is_protocol_char). The _ExplodeUrlString
mentions that it is an implementation of a regular expression, but I
am
not very good at regular expressions. I thought that the protocol
part
is everything in front of "://", but perhaps that is a bit
simplistic.