code: function(url, proxy) {
          var sameOrigin = url.indexOf("http") !== 0;
          var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);
          if (urlParts) {
              var location = window.location;
              sameOrigin =
                  urlParts[1] == location.protocol &&
                  urlParts[3] == location.hostname;
              var uPort = urlParts[4], lPort = location.port;
              if (uPort != 80 && uPort != "" || lPort != "80" && lPort != "") {
                  sameOrigin = sameOrigin && uPort == lPort;
              }
          }
          if (!sameOrigin) {
              if (proxy) {
                  if (typeof proxy == "function") {
                      url = proxy(url);
                  } else {
                      url = proxy + encodeURIComponent(url);
                  }
              }
          }
          return url;
      }
docs: Method: makeSameOrigin
  Using the specified proxy, returns a same origin url of the provided url.
  
  Parameters:
  url - {String} An arbitrary url
  proxy {String|Function} The proxy to use to make the provided url a
  same origin url.
  
  Returns
  {String} the same origin url. If no proxy is provided, the returned url
  will be the same as the provided url.