Added in code from bug #1935 to improve auto-protocol handling on urls

This commit is contained in:
kipp@netscape.com
1999-01-09 02:00:42 +00:00
parent 05d0b476ac
commit c6ac9c7321
2 changed files with 50 additions and 14 deletions

View File

@@ -1200,13 +1200,31 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
// if no scheme (protocol) is found, assume http.
if ( ((colon=urlSpec.Find(':')) == -1) // no colon at all
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
&& ((port=urlSpec.CharAt(colon+1)) < '9')
&& (port > '0') )
) {
nsString httpDef("http://");
urlSpec.Insert(httpDef, 0, 7);
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
&& ((port=urlSpec.CharAt(colon+1)) <= '9')
&& (port > '0') )) {
// find host name
int hostPos = urlSpec.FindCharInSet("./:");
if (hostPos == -1) {
hostPos = urlSpec.Length();
}
// extract host name
nsAutoString hostSpec;
urlSpec.Left(hostSpec, hostPos);
// insert url spec corresponding to host name
if (hostSpec.EqualsIgnoreCase("www")) {
nsString ftpDef("http://");
urlSpec.Insert(ftpDef, 0, 7);
} else if (hostSpec.EqualsIgnoreCase("ftp")) {
nsString ftpDef("ftp://");
urlSpec.Insert(ftpDef, 0, 6);
} else {
nsString httpDef("http://");
urlSpec.Insert(httpDef, 0, 7);
}
}
// Give web-shell-container right of refusal