anchor.diff:  -module(url).
  --export([parse/1, get_path_query/1, to_string/1, test/0]).
  +-export([parse/1, get_path_query/1, to_string/1, join/2, test/0]).
   
   -include("url.hrl").
   
   parse(S) ->
       case string:str(S, "://") of
   	0 ->
  -	    xxx;
  +	    parse_path(#url{type = relative}, S);
   	_->
   	    URL = parse_scheme(#url{type = absolute}, S),
   	    case URL#url.path of
  
positive.code: 
  parse_port(URL, Port, [C | S]) ->
      parse_port(URL, [C | Port], S).
  
  parse_path(URL, Path, []) ->
      URL#url{path = lists:reverse(Path)};
  
negative.code:     ok.
  
  test() ->
      %% Empty path
      {url, absolute, http, "spaceboyz.net", 80, "/", "", ""} = parse("http://spaceboyz.net"),
      {url, absolute, http, "example", 80, "/", "test", ""} = parse("http://example?test"),
      {url, absolute, https, "example", 8443, "/", "test", ""} = parse("https://example:8443?test"),
      %% Bidirectional
      test_url("http://spaceboyz.net/", {url, absolute, http, "spaceboyz.net", 80, "/", "", ""}),
      test_url("https://nsa.gov:8443/login?secure#form", {url, absolute, https, "nsa.gov", 8443, "/login", "secure", "form"}),
      %% Join
      {url, absolute, http, "spaceboyz.net", 80, "/~user/", "", ""} = join(parse("http://spaceboyz.net/~astro/foo/baz.html"), parse("./../../~user/")).
  
  