home *** CD-ROM | disk | FTP | other *** search
- /*
- 2009 - Copyright by Bee <http://www.honeybeenet.altervista.org>.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
- function beefree_is_protocol(address, protocol)
- {
- if(protocol.length > address.length)
- return false;
- address = address.toLowerCase();
- return address.indexOf(protocol.toLowerCase()) == 0;
- }
-
- function beefree_is_protocol_web(address)
- {
- return beefree_is_protocol(address, "http://") || beefree_is_protocol(address, "https://");
- }
-
- function beefree_is_hyperlink(address)
- {
- if(address.length == 0)
- return false;
- if( beefree_is_protocol_web(address) ||
- beefree_is_protocol(address, "javascript:") ||
- address.indexOf(":") < 0)
- return true;
- var index = address.indexOf("?");
- if(index >= 0)
- address = address.substr(0, index);
- return address.indexOf(":") < 0 || address.indexOf(":") > 10;
- }
-
- function beefree_is_anchor(address)
- {
- if(address.length == 0)
- return false;
- return address.substr(0, 1) == "#";
- }
-
- function beefree_is_anchor_magic(address, base)
- {
- if(address.length == 0)
- return false;
- return (address.substr(0, 1) == "#") ||
- (address.substr(0, 1+base.length) == base + "#");
- }
-
- function beefree_make_uri_object(aURL, aOriginCharset, aBaseURI)
- {
- //https://developer.mozilla.org/en/nsIURI
- var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
- return ioService.newURI(aURL, aOriginCharset, aBaseURI);
- }
-
- function beefree_host_from_address_ext(url, charset /* = null */)
- {
- var locURI = beefree_make_uri_object(url, charset, null);
- return locURI.asciiHost;
- }
-
- function beefree_host_from_address(url)
- {
- return beefree_host_from_address_ext(url, null);
- }
-
-
-