const API_BASE_URL = "http://localhost/";
191324
private static function build_request($request) {
        if (!extension_loaded ("curl")) {
            throw new RestClientException("cURL extension not found. You need to enable cURL in your php.ini or another configuration you have.");
        }

        if (!isset($request["method"])) {
            throw new RestClientException("No HTTP METHOD specified");
        }

        if (!isset($request["uri"])) {
            throw new RestClientException("No URI specified");
        }

        // Set headers
        $headers = array("accept: application/json");
        $json_content = true;
        $form_content = false;
        $default_content_type = true;

        if (isset($request["headers"]) && is_array($request["headers"])) {
            foreach ($request["headers"] as $h => $v) {
                //$h = strtolower($h);
                //$v = strtolower($v);

                if ($h == "content-type") {
                    $default_content_type = false;
                    $json_content = $v == "application/json";
                    $form_content = $v == "application/x-www-form-urlencoded";
                }

                array_push ($headers, $h.": ".$v);
            }
        }
        if ($default_content_type) {
            array_push($headers, "content-type: application/json");
        }

        // Build $connect
        $connect = curl_init();

        curl_setopt($connect, CURLOPT_USERAGENT, "Rest Client");
        curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($connect, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($connect, CURLOPT_TIMEOUT, isset($request["timeout"]) ? $request["timeout"] : 0);
        //curl_setopt($connect, CURLOPT_CAINFO, $GLOBALS["LIB_LOCATION"] . "/cacert.pem");
        curl_setopt($connect, CURLOPT_CUSTOMREQUEST, $request["method"]);
        curl_setopt($connect, CURLOPT_HTTPHEADER, $headers);

        // Set parameters and url
        if (isset ($request["params"]) && is_array($request["params"]) && count($request["params"]) > 0) {
            $request["uri"] .= (strpos($request["uri"], "?") === false) ? "?" : "&";
            $request["uri"] .= self::build_query($request["params"]);
        }
        curl_setopt($connect, CURLOPT_URL, /*self::API_BASE_URL .*/ $request["uri"]);

        // Set data
        if(isset($request["data"])) {
            if($json_content) {
                if(gettype($request["data"]) == "string") {
                    json_decode($request["data"], true);
                } else {
                    $request["data"] = json_encode($request["data"], JSON_UNESCAPED_SLASHES);
                }

                if(function_exists('json_last_error')) {
                    $json_error = json_last_error();
                    if ($json_error != JSON_ERROR_NONE) {
                        throw new RestClientException("JSON Error [{$json_error}] - Data: ".$request["data"]);
                    }
                }
            } else if ($form_content) {
                $request["data"] = self::build_query($request["data"]);
            }

            curl_setopt($connect, CURLOPT_POSTFIELDS, $request["data"]);
        }

        return $connect;
    }
503199
function(url) {
		if (url.match(/^http/i)) {
			return url;
		}
		if (url.substr(0,2) === '//') {
			return window.location.protocol + url;
		}
		var root = window.location.protocol + '//' + window.location.host,
			reg  = /[^\/]+\/\.\.\//,
			ret;
		if (url.substr(0, 1) === '/') {
			ret = root + url;
		} else {
			ret = root + window.location.pathname.replace(/\/[^\/]+$/, '/') + url;
		}
		ret = ret.replace('/./', '/');
		while(reg.test(ret)) {
			ret = ret.replace(reg, '');
		}
		return ret;
	}
277405
function baseRequest(uri, cb) {
  var url = `${BASE_URL}${uri}`;
  request(url, function (error, response, body) {
    debug(`Url: ${url} statusCode: ${response && response.statusCode}`);
    if(error || (response && response.statusCode === 404)) {
       cb(error || response);
    }
    cb(null, JSON.parse(body));
  });
}
872325
def get_url(self, cmd, **args):
        """"""
        return self.http.base_url + self._mkurl(cmd, *args)
119314
function() {
      var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError();
      if (this.isNew()) return base;
      return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);
    }
472630
function() {
            var args = Array.prototype.slice.call(arguments, 0);
            args.splice(0,0, configs.staticDirectory);
            return Urls.base.apply(Urls, args);
        }
221308
function _main() {
  const srcIndexPath = join(DIST_DIR, 'index.html');
  const src404BodyPath = join(SRC_DIR, '404-body.html');
  const dst404PagePath = join(DIST_DIR, '404.html');

  const srcIndexContent = readFileSync(srcIndexPath, 'utf8');
  const src404BodyContent = readFileSync(src404BodyPath, 'utf8');
  const dst404PageContent = srcIndexContent.replace(/<body>[\s\S]+<\/body>/, src404BodyContent);

  if (dst404PageContent === srcIndexContent) {
    throw new Error(
        'Failed to generate \'404.html\'. ' +
        'The content of \'index.html\' does not match the expected pattern.');
  }

  writeFileSync(dst404PagePath, dst404PageContent);
}
1106949
function LocationUrl(url, pathPrefix, appBaseUrl) {
  pathPrefix = pathPrefix || '';

  /**
   * Parse given html5 (regular) url string into properties
   * @param {string} newAbsoluteUrl HTML5 url
   * @private
   */
  this.$$parse = function(newAbsoluteUrl) {
    var match = matchUrl(newAbsoluteUrl, this);

    if (match.path.indexOf(pathPrefix) !== 0) {
      throw Error('Invalid url "' + newAbsoluteUrl + '", missing path prefix "' + pathPrefix + '" !');
    }

    this.$$path = decodeURIComponent(match.path.substr(pathPrefix.length));
    this.$$search = parseKeyValue(match.search);
    this.$$hash = match.hash && decodeURIComponent(match.hash) || '';

    this.$$compose();
  };

  /**
   * Compose url and update `absUrl` property
   * @private
   */
  this.$$compose = function() {
    var search = toKeyValue(this.$$search),
        hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';

    this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
    this.$$absUrl = composeProtocolHostPort(this.$$protocol, this.$$host, this.$$port) +
                    pathPrefix + this.$$url;
  };


  this.$$rewriteAppUrl = function(absoluteLinkUrl) {
    if(absoluteLinkUrl.indexOf(appBaseUrl) == 0) {
      return absoluteLinkUrl;
    }
  }


  this.$$parse(url);
}
428462
function(route, args, base) {
            base = base || "";
            args = args || {};
            var url = route;
            url = url.replace("#!/","#").replace("#!", "#").replace("#", "");
            _.map(args, function(value, attr) {
                url = url.replace("\:"+attr, value);
            });
            return base+"#/"+url;
        }
921548
function parseURL(url) {

	const endpoint = {};

	const purl = urlParser.parse(url, true);

	if (purl.protocol && purl.protocol.startsWith('http')) {
		endpoint.protocol = purl.protocol.slice(0, -1);
		if (purl.hostname) {
			endpoint.hostname = purl.hostname;

			if (purl.port) {
				endpoint.port = parseInt(purl.port);
			}

		} else {
			throw new Error('InvalidURL: missing hostname.');
		}

	} else {
		throw new Error('InvalidURL: url must start with http or https.');
	}

	return endpoint;
}
640084
function resolveUrl(base, url) {
  var value = '';
  if (url.indexOf('://') != -1) {
    // Likely absolute...
    value = url;
  } else {
    // Combine by smashing together and letting the browser figure it out.
    if (url.length && url[0] == '/') {
      // URL is absolute, so strip base to just host.
      var i = url.indexOf('://') + 3;
      i = url.indexOf('/', i);
      if (i != -1) {
        value = base + url;
      } else {
        value = base.substr(0, i) + url;
      }
    } else {
      // URL is relative, so combine with base.
      if (base[base.length] == '/') {
        value = base + '/' + url;
      } else {
        value = base + '/../' + url;
      }
    }
  }
  return value;
}
1230595
def get_endpoint(self, endpoint=None):
        """"""
        base_url = self.api_config.api_url
        if not endpoint:
            if 'localhost' in base_url:
                endpoint = ''
            else:
                endpoint = ENDPOINTS[self.endpoint_type]

        endpoint = '/'.join([p.strip('/') for p in (base_url, endpoint)]).strip('/')
        self.logger.info("Using Endpoint: %s", endpoint)
        return endpoint
948365
function set_base_url($url = '')
    {
        if (empty($url)) {
            if (!empty($_SERVER['HTTP_HOST'])) {
                $this->url = 'http://' . $_SERVER['HTTP_HOST'];
            }
            else {
                $this->url = '';
            }
        }
        else {
            // Strip any trailing slashes for consistency (relative
            // URLs may already start with a slash like "/file.html")
            if (substr($url, -1) == '/') {
                $url = substr($url, 0, -1);
            }
            $this->url = $url;
        }
    }
1240940
function buildHttpURL(uri) {
    var port     = weinre_port
    var pathname = weinre_pathname

    if (pathname == "/index.html") pathname = "/"

    if (weinre_protocol == "file:") {
        return uri
    }

    else if (weinre_protocol == "http:") {
        if (port != "") port = ":" + port

        return weinre_protocol + "//" + weinre_host + port + pathname + uri
    }

    else if (weinre_protocol == "https:") {
        if (port != "") port = ":" + port

        return weinre_protocol + "//" + weinre_host + port + pathname + uri
    }
}
337936
function extractProtocolHost(url) {
    const urlNoQuery = url.split('?')[0];
    const [protocol, hostAndPath] = urlNoQuery.split('//');
    const host = hostAndPath.split('/')[0];
    return `${protocol}//${host}`;
}
73826
function createUrlFromEndpointAndOptions (endpoint, options) {
  const query = qs.stringify(options);
  const baseURL = `${host}${endpoint}`;
  return query ? `${baseURL}?${query}` : baseURL;
}
269220
function() {
      var base =
        _.result(this, 'urlRoot') ||
        _.result(this.collection, 'url') ||
        urlError();
      if (this.isNew()) return base;
      return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id);
    }