code: function parseUrlOrigin(url) {
     // url could be domain-relative
     // url could give a domain
  
     // cross origin means:
     //    same domain
     //    same port
     //    some protocol
     // so, same everything up to the first (single) slash 
     // if such is given
     //
     // can ignore everything after that   
     
     var URL_HOST_PATTERN = /(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/,
  
           // if no match, use an empty array so that
           // subexpressions 1,2,3 are all undefined
           // and will ultimately return all empty
           // strings as the parse result:
         urlHostMatch = URL_HOST_PATTERN.exec(url) || [];
     
     return {
        protocol:   urlHostMatch[1] || '',
        host:       urlHostMatch[2] || '',
        port:       urlHostMatch[3] || ''
     };
  }
docs: /* turn any url into an object like window.location