Monday, November 08, 2010 at 12:06 AM.
system.verbs.builtins.string.urlSplit
on urlSplit (url) { <<Thursday, November 11, 1999 at 3:00:08 AM by AR <<Implemented as a kernel verb in Frontier 6.1. <<Old code <<on urlSplit (url) << 10/31/97 at 1:35:47 PM by DW -- moved from toys.urlSplit <<assume a valid complete URL, split it into three parts, return as a list: <<list [1]: the protocol, e.g. http:// <<list [2]: the domain, e.g. www.yourserver.com <<list [3]: the path, e.g. essays/97/04/myLife.html <<on urlError () <<scriptError ("The URL must be of the form 'http://www.server.com/hello.html'.") <<local (ix) <<ix = string.patternMatch (":", url) <<if ix == 0 <<urlError () <<local (ixend, i) <<i = ix <<loop <<if i++ > sizeof (url) <<urlError () <<if url [i] != '/' <<ixend = i - 1 <<break <<protocol = string.mid (url, 1, ixend) <<url = string.delete (url, 1, sizeof (protocol)) << <<ix = string.patternMatch ("/", url) <<if ix == 0 <<urlError () <<domain = string.mid (url, 1, ix - 1) <<path = string.delete (url, 1, ix) << <<return ({protocol, domain, path}) kernel (string.urlsplit)} <<bundle <<test code <<dialog.alert (urlsplit ("http://www.yourserver.com/")) <<dialog.alert (urlsplit ("http://www.yourserver.com/essays/97/04/myLife.html"))
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.