mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 12:36:51 +03:00
[project @ 2002-12-25 22:46:14 by bursa]
Changes to url handling. svn path=/import/netsurf/; revision=56
This commit is contained in:
parent
668dfb4884
commit
364bfbee5f
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* $Id: browser.c,v 1.13 2002/12/25 21:38:45 bursa Exp $
|
* $Id: browser.c,v 1.15 2002/12/25 22:47:03 bursa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "netsurf/riscos/font.h"
|
#include "netsurf/riscos/font.h"
|
||||||
@ -945,7 +945,6 @@ void browser_window_redraw_boxes(struct browser_window* bw, struct box_position*
|
|||||||
|
|
||||||
char *url_join(const char* new, const char* base)
|
char *url_join(const char* new, const char* base)
|
||||||
{
|
{
|
||||||
xmlURI* uri;
|
|
||||||
char* ret;
|
char* ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -954,38 +953,41 @@ char *url_join(const char* new, const char* base)
|
|||||||
if (base == 0)
|
if (base == 0)
|
||||||
{
|
{
|
||||||
/* no base, so make an absolute URL */
|
/* no base, so make an absolute URL */
|
||||||
uri = xmlParseURI(new);
|
ret = xcalloc(strlen(new) + 10, sizeof(char));
|
||||||
assert(uri != 0);
|
|
||||||
|
|
||||||
if (uri->scheme == 0)
|
/* check if a scheme is present */
|
||||||
uri->scheme = "http";
|
i = strspn(new, "abcdefghijklmnopqrstuvwxyz");
|
||||||
|
if (new[i] == ':')
|
||||||
if (uri->server == 0) {
|
{
|
||||||
uri->server = uri->path;
|
strcpy(ret, new);
|
||||||
uri->path = 0;
|
i += 3;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(ret, "http://");
|
||||||
|
strcat(ret, new);
|
||||||
|
i = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make server name lower case */
|
||||||
|
for (; ret[i] != 0 && ret[i] != '/'; i++)
|
||||||
|
ret[i] = tolower(ret[i]);
|
||||||
|
|
||||||
|
/* http://www.example.com -> http://www.example.com/ */
|
||||||
|
if (ret[i] == 0)
|
||||||
|
{
|
||||||
|
ret[i] = '/';
|
||||||
|
ret[i+1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlNormalizeURIPath(ret + i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* relative url */
|
/* relative url */
|
||||||
char* uri_string = xmlBuildURI(new, base);
|
ret = xmlBuildURI(new, base);
|
||||||
uri = xmlParseURI(uri_string);
|
|
||||||
xfree(uri_string);
|
|
||||||
assert(uri != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make server name lower case */
|
|
||||||
assert(uri->scheme != 0 && uri->server != 0);
|
|
||||||
for (i = 0; i < strlen(uri->server); i++)
|
|
||||||
uri->server[i] = tolower(uri->server[i]);
|
|
||||||
|
|
||||||
/* http://www.example.com -> http://www.example.com/ */
|
|
||||||
if (uri->path == 0)
|
|
||||||
uri->path = "/";
|
|
||||||
|
|
||||||
ret = xmlSaveUri(uri);
|
|
||||||
xmlFreeURI(uri);
|
|
||||||
|
|
||||||
LOG(("ret = %s", ret));
|
LOG(("ret = %s", ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user