Return an escaped path or URL string that can be broken near path separators.
@param {string} url the path or URL to format
@return {string} the formatted path or URL
182097
function breakableUrl(url) {
        // This is for displaying in UI, so always want it escaped
        var escUrl = _.escape(url);

        // Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there
        return escUrl.replace(
            new RegExp(regexEscape("/"), "g"),
            "/" + "&#8203;"
        );
    }
1125475
function getProtohost(url) {
  if (typeof url !== 'string' || url.length === 0 || url[0] === '/') {
    return undefined
  }

  var searchIndex = url.indexOf('?')
  var pathLength = searchIndex !== -1
    ? searchIndex
    : url.length
  var fqdnIndex = url.substr(0, pathLength).indexOf('://')

  return fqdnIndex !== -1
    ? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
    : undefined
}
618409
function parsePath(req) {
  // get path if preprocessed or otherwise separate path from query string
  const path = req.path || (req.url && req.url.split('?')[0]) || '';
  // ignore start and end slashes, and split the path
  return path.replace(/^\/|\/$/g, '').split('/');
}
793810
function (url) {
                if (!url)
                    return "";

                var urlParts = url.split("/"),
                    newPath = "";

                for (var i = 0, len = urlParts.length; i < len; i++) {
                    var part = urlParts[i];

                    if (!part || part.length === 0
                        || part.indexOf(":") != -1
                        || part === "."
                        || part === ".."
                        || part === "null"
                        || part === "undefined") {
                        continue;
                    }

                    if (newPath.length !== 0) {
                        newPath = newPath + "/";
                    }

                    newPath = newPath + part;
                }

                return newPath;
            }
337936
function extractProtocolHost(url) {
    const urlNoQuery = url.split('?')[0];
    const [protocol, hostAndPath] = urlNoQuery.split('//');
    const host = hostAndPath.split('/')[0];
    return `${protocol}//${host}`;
}
640883
function urlToUri(url) {
  let parts;

  if (!isUrl(url)) {
    throw new Error('Invalid url ' + url);
  }
  parts = urlParse.parse(url);

  return `${parts.hostname}${decodeURIComponent(parts.path)}`;
}
643257
function normalizeUrl(url, pathStripRe) {
  if (url.indexOf('/') !== -1) {
    return url.replace(/^file\:\/\//, '').replace(pathStripRe, '');
  } else {
    return '/' + url;
  }
}
2840
private String extractPathFromUrl(String url) {
        String path = url.replaceAll(".+://.+?(?=/)", "");
        if (!path.startsWith("/")) {
            throw new RuntimeException("Path must start with '/': " + path);
        }
        return path;
    }
1192871
function() {
            var parts = Array.prototype.slice.call(arguments, 0);
            return Urls.normalize(parts.join('/'));
        }
909366
function getName () {
    const pathname = url.parse(parts[parts.length - 1]).pathname;

    return pathname ? pathname.replace('/', '') : pathname;
  }
882791
function parseUrl (url) {
  const regex = /(https?).*\/(.+)\/thread\/(\d+)/g
  let protocol
  let board
  let threadNo

  try {
    [, protocol, board, threadNo] = regex.exec(url)
  } catch (err) {
    throw new Error('Invalid 4chan URL!')
  }

  return {
    protocol,
    board,
    threadNo: Number.parseInt(threadNo)
  }
}
1144631
function(url) {
			var paths = this.paths;
			for(var index = 0; index < paths.length; index++) {
				var path = paths[index];
				if (path === url.substring(0, path.length)) {
					return url.substring(path.length);
				}
			}
			return url;
		}
958613
function formatURL(httpOptions) {
  var url;
  if (httpOptions.protocol) {
    url = httpOptions.protocol;
  } else {
    url = 'http:';
  }
  url += '//';
  if (httpOptions.auth) {
    url += httpOptions.auth + '@';
  }
  if (httpOptions.host) {
    url += httpOptions.host;
  } else if (httpOptions.hostname) {
    url += httpOptions.hostname;
  } else {
    url += 'localhost';
  }
  if (httpOptions.port && !url.includes(':' + httpOptions.port)) {
    url += ':' + httpOptions.port;
  }
  if (httpOptions.path) {
    url += httpOptions.path;
  } else {
    url += '/';
  }
  return url;
}
845530
function(url){

	var retlist = [];

	// Pull parameters.
	var tmp = url.split('?');
	var path = '';
	var parms = [];
	if( ! tmp[1] ){ // catch bad url--nothing before '?'
	    parms = tmp[0].split('&');
	}else{ // normal structure
	    path = tmp[0];
	    parms = tmp[1].split('&');
	}

	// Decompose parameters.
	each(parms, function(p){
	    var c = _first_split('=', p);
	    if( ! c[0] && ! c[1] ){
		retlist.push([p]);
	    }else{
		retlist.push(c);		  
	    }
	});
	
	return retlist;
    }
1279707
def is_escaped(url):
    '''
    
    '''
    scheme = urlparse(url).scheme
    if not scheme:
        return url.startswith('|')
    elif scheme == 'salt':
        path, saltenv = parse(url)
        if salt.utils.platform.is_windows() and '|' in url:
            return path.startswith('_')
        else:
            return path.startswith('|')
    else:
        return False
526152
function (url) {
        if (typeof url !== 'string') {
            throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof url}\``);
        }
        url = url.trim();
        if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
            return url;
        }
        return url.replace(/^(?!(?:\w+:)?\/\/)/, 'https://');
    }
1215956
function(url) {

        // Note: this is rudamentary.. not sure yet if it handles every case.
        if (/^https?:\/\//i.test(url)) {
            // absolute
            return url;
        }

        var baseParts = this.parseUrl(this.baseUrl);
        if (url.charAt('/')) {
            // Url starts with a slash
            return baseParts.root + url;
        }

        // Url does not start with a slash, we need grab the base url right up until the last slash.
        var newUrl = baseParts.root + '/';
        if (baseParts.path.lastIndexOf('/')!==-1) {
            newUrl = newUrl = baseParts.path.subString(0, baseParts.path.lastIndexOf('/')) + '/';
        }
        newUrl+=url;
        return url;

    }