/* -------------------------------- ** FUNCTION: ** fnGetProtocolFromURLString ** DESCRIPTION: ** This function returns the url protocol string ** from the beginning of a url, such as 'http://' etc ** If no valid protocol string is present then the ** function returns -1. The url string is left ** unchanged. ** DEPENDENCIES: ** fnStripLeadingSpaceFromString ** SEE ALSO: ** DATE: ** -------------------------------- */ function fnGetProtocolFromURLString(sURLString) { //-- Verify parameters if (sURLString == null) { //-->-->-->-->-->-->-->-->-->-->-->--> //-- write out some nasty error message //-- somewhere, mortally insulting the programmer //-- for such a ridiculous error return -1; } var sReturn = new String(""); var sTest = sURLString; sTest = sTest.toLowerCase(); sTest = fnStripLeadingSpaceFromString(sTest); /* -->-->-->-->-->-->-->-->-->--> //-- I have forgotten the syntax for this var rxProtocol = new RegExp("^([a-z]{2,6}:[/]{0,2})", "gi"); if (sTest.replace(rxProtocol, "") == ???) { return sReturn; } -->-->-->-->-->-->-->-->-->-->--> */ if (sTest.substring(0,7) == "http://") { return "http://"; } if (sTest.substring(0, 6) == "http:/") { return "http:/"; } if (sTest.substring(0,8) == "https://") { return "https://"; } if (sTest.substring(0, 7) == "https:/") { return "https:/"; } if (sTest.substring(0, 7) == "nttp://") { return "nttp://"; } if (sTest.substring(0, 6) == "ftp://") { return "ftp://"; } if (sTest.substring(0, 6) == "dict://") { return "dict://"; } return -1; } //-- fnGetProtocolFromURLString()