Source: site.view [edit]
Function name: goUrl
Arguments: url
Description: Dispatches to a URL. Will add "http://" and will also add .com, .org, or .net if needed (tests for existance of site)
Page type: html
Render function:  
Module: site

Page source:

<webl>

// Tests validity of URL by asking for HEAD information, 
//   without pulling entire page (should be faster).
var TestUrl = fun(url, ext)
   var t = HeadURL(url + ext);
   url + ext
end;

// Checks if url already has a .com, .net, or .org
var noExtension = fun(url)
   url = Str_ToLowerCase(url);
   return ((Str_IndexOf(url, ".com") == -1) and 
                  (Str_IndexOf(url, ".net") == -1) and
                  (Str_IndexOf(url, ".org") == -1))
end;

// Main function
  if (Str_IndexOf(`://`, url) == -1) then
     if (Str_IndexOf(`www`, url) == -1) then
        url = "http://www." + url
     else
        url = "http://" + url
     end
  end;
  if (noExtension(url)) then
     // Try the url, then with each extension
     var newUrl = (TestUrl(url, "") ? 
                  TestUrl(url, ".com") ? 
                  TestUrl(url, ".org") ?  
                  TestUrl(url, ".net") ?
                  nil);
     // If found, redispatch to new page
     if (newUrl != nil) then
        `<head><META HTTP-EQUIV="Refresh"; CONTENT="0;URL=` + newUrl + `"></head>`
     else
        `Couldn't find url: ` + url
     end
  end;
</webl>