/*
Create URL to call bridge app
776164
protected String buildBridgeBaseURL() {
        String protocol = "443".equals(bridgeAppPort) ? "https" : "http";
        return MessageFormat.format("{0}://{1}:{2}/bridge",
                                    protocol,
                                    bridgeAppHost,
                                    bridgeAppPort);
    }
80047
protected String callBridge(RestHttpHelper restHelper,
                                String snapshotURL,
                                String snapshotBody) {
        log.info("Making RESTORE call to URL {} with body {}",
                 snapshotURL, snapshotBody);

        try {
            Map<String, String> headers = new HashMap<>();
            headers.put(HttpHeaders.CONTENT_TYPE, "application/json");
            RestHttpHelper.HttpResponse response =
                restHelper.put(snapshotURL, snapshotBody, headers);
            int statusCode = response.getStatusCode();
            if (statusCode != 201) {
                throw new RuntimeException("Unexpected response code: " +
                                           statusCode);
            }
            return response.getResponseBody();
        } catch (Exception e) {
            throw new TaskException("Exception encountered attempting to " +
                                    "initiate snapshot request. " +
                                    "Error reported: " + e.getMessage(), e);
        }
    }
923983
def bridge_param(_param, _method, *args, **kwargs):
    
    assert callable(_method), "method %r is not callable" % (_method, )
    f = Fiber(debug_depth=1, debug_call=_method)
    f.add_callback(drop_param, _method, *args, **kwargs)
    f.add_callback(override_result, _param)
    return f.succeed()
1230027
function getURL(url, callback) {
    Espruino.callProcessor("getURL", { url : url, data : undefined }, function(result) {
      if (result.data!==undefined) {
        callback(result.data);
      } else {
        var resultUrl = result.url ? result.url : url;
        if (typeof process === 'undefined') {
          // Web browser
          $.get( resultUrl, function(d) {
            callback(d);
          }, "text").error(function(xhr,status,err) {
            console.error("getURL("+JSON.stringify(url)+") error : "+err);
            callback(undefined);
          });
        } else {
          // Node.js
          if (resultUrl.substr(0,4)=="http") {
            var m = resultUrl[4]=="s"?"https":"http";

            var http_options = Espruino.Config.MODULE_PROXY_ENABLED ? {
              host: Espruino.Config.MODULE_PROXY_URL,
              port: Espruino.Config.MODULE_PROXY_PORT,
              path: resultUrl,
            } : resultUrl;

            require(m).get(http_options, function(res) {
              if (res.statusCode != 200) {
                console.log("Espruino.Core.Utils.getURL: got HTTP status code "+res.statusCode+" for "+url);
                return callback(undefined);
              }
              var data = "";
              res.on("data", function(d) { data += d; });
              res.on("end", function() {
                callback(data);
              });
            }).on('error', function(err) {
              console.error("getURL("+JSON.stringify(url)+") error : "+err);
              callback(undefined);
            });
          } else {
            require("fs").readFile(resultUrl, function(err, d) {
              if (err) {
                console.error(err);
                callback(undefined);
              } else
                callback(d.toString());
            });
          }
        }
      }
    });
  }
1275936
public static URL buildUrl(String scheme, String host, int port, String path, Map<String, String> parameters) throws MalformedURLException {
        checkSchemeAndPort(scheme, port);
        StringBuilder buffer = new StringBuilder();
        if (!host.startsWith(scheme + "://")) {
            buffer.append(scheme).append("://");
        }
        buffer.append(host);
        if (port > 0) {
            buffer.append(':');
            buffer.append(port);
        }
        if (path == null) {
            path = "/";
        }
        buffer.append(path);

        if (!parameters.isEmpty()) {
            buffer.append('?');
        }
        int size = parameters.size();
        for (Map.Entry<String, String> entry : parameters.entrySet()) {
            buffer.append(entry.getKey());
            buffer.append('=');
            Object value = entry.getValue();
            if (value != null) {
                String string = value.toString();
                try {
                    string = URLEncoder.encode(string, UTF8);
                } catch (UnsupportedEncodingException e) {
                    // Should never happen, but just in case
                }
                buffer.append(string);
            }
            if (--size != 0) {
                buffer.append('&');
            }
        }

        /*
         * RequestContext requestContext = RequestContext.getRequestContext(); Auth auth = requestContext.getAuth(); if (auth != null &&
         * !ignoreMethod(getMethod(parameters))) { buffer.append("&api_sig="); buffer.append(AuthUtilities.getSignature(sharedSecret, parameters)); }
         */

        return new URL(buffer.toString());
    }
365307
function Router_createUrl(route, params) {
        var routeRule, url, anchor = '', routes;

        if (!Type.isString(route)) {
            throw new error.HttpError(500, {route: route}, 'RouteRule.createUrl: route must be string type');
        }
        if (!params) {
            params = {};
        } else if (!Type.isObject(params)) {
            throw new error.HttpError(500, {params: params}, 'RouteRule.createUrl: params must be object type');
        }

        Object.keys(params).forEach(function (item) {
            if (item === '#') {
                anchor = '#' + params['#'];
                delete params['#'];
            }
        });

        params = core.copy(params);
        routes = this.routes.slice();

        while (routes.length) {
            routeRule = routes.shift();
            url = routeRule.createUrl(route, params);
            if (url) {
                return this.normalizeUrl('/' + url + anchor);
            }
        }

        url = '/' + this.trim(route, '/');

        if (Object.keys(params).length > 0) {
            url += '?' + this.buildQuery(params);
        }

        return this.normalizeUrl(url + anchor);
    }
1063097
def build_api_url(host=REMOTES['default']['ip'],
                  port=REMOTES['default']['port'],
                  path=REMOTES['default']['path'],
                  username=None,
                  password=None,
                  ssl=False):
    """"""
    credentials = make_http_credentials(username, password)
    scheme = 'http'
    if not path:
        path = ''
    if path and not path.startswith('/'):
        path = "/%s" % path
    if ssl:
        scheme += 's'
    return "%s://%s%s:%i%s" % (scheme, credentials, host, port, path)
1329117
def _constructUrl(self, route):
        """"""
        return liburls.api(
            self.options['rootUrl'],
            self.serviceName,
            self.apiVersion,
            route.rstrip('/'))
1278192
function makeUrl(s) {
  var search = window.location.search;

  // Remove previous grep query parameter if present
  if (search) {
    search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
  }

  return (
    window.location.pathname +
    (search ? search + '&' : '?') +
    'grep=' +
    encodeURIComponent(escapeRe(s))
  );
}
118819
function makeRequest(apiKey, path, opts, callback) {
    var 
        key,
        req,
        dataStr = '';
        
    if(callback === undefined) {
        throw 'No callback defined';
        return;
    }

    path = '/plus/v1/' + path + '?key=' + apiKey;
    for(key in opts) {
        path += '&' + key + '=' + opts[key];
    }

    req = https.request({
        host: 'www.googleapis.com',
        port: 443,
        path: path,
        method: 'GET'
    }, function(res) {
        res.on('data', function(data) {
            dataStr += data;
        });
        
        res.on('end', function() {
            if(opts.alt === undefined || opts.alt.toLowerCase() == 'json') {
                try {
                    callback(null, JSON.parse(dataStr));
                } catch(err) {
                    callback(null, dataStr);
                }
            }
            else {
                callback(null, dataStr);
            }
        });
        
        res.on('close', function () {
            res.emit('end');
        });
    });
    req.end();
    
    req.on('error', function(err) {
        callback(err);
    });

    return req;
}
1208492
function routeUrl(location) {
    if (location.hash.indexOf('#/register') == 0) {
        var hashparts = location.hash.split('?');
        var params = {};
        if (hashparts.length == 2) {
            var pairs = hashparts[1].split('&');
            for (var i = 0; i < pairs.length; ++i) {
                var parts = pairs[i].split('=');
                if (parts.length != 2) continue;
                params[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
            }
        }
        window.matrixChat.showScreen('register', params);
    }
}
335284
function requestUrl(url, callback) {
  var req = new XMLHttpRequest();
  req.addEventListener("load", function () {
    callback(req.responseText);
  });
  req.open("GET", url);
  req.send();
}
96421
function createWebservice (opts) {
    var server = new Hapi.Server(opts.host, opts.port, {
        cors: {
            methods: ['GET']
        }
    });
    defineRoutes(server, opts);
    return {
        address: 'http://' + opts.host + ':' + opts.port + '/',
        hapi: server,
        options: opts,
        start: server.start.bind(server)
    };
}
73826
function createUrlFromEndpointAndOptions (endpoint, options) {
  const query = qs.stringify(options);
  const baseURL = `${host}${endpoint}`;
  return query ? `${baseURL}?${query}` : baseURL;
}
211998
def _build_url(self):
        """"""
        if self.connection.get("username") and self.connection.get("password"):
            auth = "%s:%s@" % (self.connection["username"],
                               self._encoded_password)
        else:
            auth = ""

        # Optional port number
        port = self.connection.get("port")
        port = ":" + port if port else ""

        self.connection["mount_url"] = "%s://%s%s%s/%s" % (
            self.protocol, auth, self.connection["url"], port,
            self.connection["share_name"])
693161
private void createUrl(String accessToken, String apiKey){
        wsuri = new Routes().getWsuri().replace(":access_token", accessToken).replace(":api_key", apiKey);
    }
709063
function createRootSymLink() {
    var li1 = process.argv[1].lastIndexOf('\\'), li2 = process.argv[1].lastIndexOf('/');
    if (li2 > li1) { li1 = li2; }
    var AppPath = process.argv[1].substring(0,li1);
    var p1 = resolve(AppPath + "/" + nativescriptAppPath);
    var p2 = resolve(AppPath + "/" + webAppPath);
    if (debugging) {
        console.log("Path: ", p1, p2);
    }
    fs.symlinkSync(p2, p1, 'junction');
}