fix bug 36455, unable to go to url with port but without http://, clean up a if statement causing the problem, r=radha@netscape.com,adamlock@netscape.com

This commit is contained in:
andreas.otte@primus-online.de
2000-05-13 12:09:16 +00:00
parent a97b2c5c96
commit b32e9187a9

View File

@@ -2319,31 +2319,31 @@ NS_IMETHODIMP nsDocShell::CreateFixupURI(const PRUnichar* aStringURI,
return NS_OK;
// See if a protocol needs to be added
PRInt32 colon = -1;
PRInt32 colon = uriString.FindChar(':');
PRInt32 fSlash = uriString.FindChar('/');
PRUnichar port;
PRUnichar port = nsnull;;
// if no scheme (protocol) is found, assume http.
if((colon=uriString.FindChar(':') == -1) ||// no colon at all
((fSlash > -1) && (colon > fSlash)) ||// the only colon comes after the first slash
((colon < (((PRInt32)uriString.Length())-1)) && // the first char after the first colon is a digit (i.e. a port)
((port=uriString.CharAt(colon+1)) <= '9') && (port > '0')))
{
// find host name
PRInt32 hostPos = uriString.FindCharInSet("./:");
if(hostPos == -1)
hostPos = uriString.Length();
if (colon == -1 || fSlash == -1 || (fSlash > -1) && (colon > fSlash)) {
if (colon < (((PRInt32)uriString.Length())-1)) {
if (colon != -1) port = uriString.CharAt(colon+1);
if (colon == -1 || uriString.IsDigit(port)) {
// find host name
PRInt32 hostPos = uriString.FindCharInSet("./:");
if (hostPos == -1)
hostPos = uriString.Length();
// extract host name
nsAutoString hostSpec;
uriString.Left(hostSpec, hostPos);
// insert url spec corresponding to host name
if(hostSpec.EqualsIgnoreCase("ftp"))
uriString.InsertWithConversion("ftp://", 0, 6);
else
uriString.InsertWithConversion("http://", 0, 7);
} // end if colon
// extract host name
nsAutoString hostSpec;
uriString.Left(hostSpec, hostPos);
// insert url spec corresponding to host name
if (hostSpec.EqualsIgnoreCase("ftp"))
uriString.InsertWithConversion("ftp://", 0, 6);
else
uriString.InsertWithConversion("http://", 0, 7);
}
}
} // end if colon
return NS_NewURI(aURI, uriString.GetUnicode(), nsnull);
}