Attempt to extract the path component of a url String argument.
@param url the URL which may contain a path, sans scheme.
@return the path component of the URL, or "" if it contains no path.
183080
public static String stripURLScheme(String url) {
		String lcUrl = url.toLowerCase();
		for(String scheme : ALL_SCHEMES) {
			if(lcUrl.startsWith(scheme)) {
				return url.substring(scheme.length());
			}
		}
		return url;
	}
109028
public static URL extractJarURL(URL url) throws IOException {
        JarURLConnection connection = (JarURLConnection) url.openConnection();
        return connection.getJarFileURL();
    }
906003
protected URL extractURL(Object url)
    throws IOException {
    if (!(url instanceof String)) {
      return null;
    }
    return (null == url || "".equals(url)) ? null : new URL( (String) url);
  }
154854
public static String getValueFromUrl(String url, String preText, int length) {
		String urlContents = getUrlContents(url);
		int indexOf = urlContents.indexOf(preText);
		if (indexOf != -1) {
			indexOf += preText.length();
			String substring = urlContents.substring(indexOf, indexOf + length);
			return substring;
		}
		return null;
	}
555799
public static String urlFrom( String baseUrl,
                                  String... pathSegments ) {
        StringBuilder urlBuilder = new StringBuilder(baseUrl);
        if (urlBuilder.charAt(urlBuilder.length() - 1) == '/') {
            urlBuilder.deleteCharAt(urlBuilder.length() - 1);
        }
        for (String pathSegment : pathSegments) {
            if (pathSegment.equalsIgnoreCase("..")) {
                urlBuilder.delete(urlBuilder.lastIndexOf("/"), urlBuilder.length());
            } else {
                if (!pathSegment.startsWith("/")) {
                    urlBuilder.append("/");
                }
                urlBuilder.append(pathSegment);
            }
        }
        return urlBuilder.toString();
    }
436095
protected String normalizeUrl(String url) {
    try {
      URL requestURL = new URL(url);
      StringBuilder normalized = new StringBuilder(requestURL.getProtocol().toLowerCase()).append("://").append(requestURL.getHost().toLowerCase());
      if ((requestURL.getPort() >= 0) && (requestURL.getPort() != requestURL.getDefaultPort())) {
        normalized.append(":").append(requestURL.getPort());
      }
      normalized.append(requestURL.getPath());
      return normalized.toString();
    }
    catch (MalformedURLException e) {
      throw new IllegalStateException("Illegal URL for calculating the OAuth signature.", e);
    }
  }
73895
public String simpleGet(String url) throws IOException {
		final AtomicReference<String> str = new AtomicReference<>();
		simpleGetInternal(url, inputStream -> {
            try {
                str.set(IOUtils.toString(inputStream, "UTF-8"));
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }, null);

		return str.get();
	}
197450
public static String getUrlParentDir(String url) {
		try {
			UsableURI uri = UsableURIFactory.getInstance(url);
			String path = uri.getPath();
			if(path.length() > 1) {
				int startIdx = path.length()-1;
				if(path.charAt(path.length()-1) == '/') {
					startIdx--;
				}
				int idx = path.lastIndexOf('/',startIdx);
				if(idx >= 0) {
					uri.setPath(path.substring(0,idx+1));
					uri.setQuery(null);
                    return uri.toUnicodeHostString();
				}
			}
		} catch (URIException e) {
			LOGGER.warning(e.getLocalizedMessage() + ": " + url);
		}
		return null;
	}
1041943
private static String parseRelativeURL(URL url, String spec) {
        String path = url.getPath();
        String result;

        int index = path.indexOf("!/");
        if (index == -1) {
            // The "jar" protocol requires that the path contain an entry path.
            // For backwards compatibility, we do not.  Instead, we just
            // canonicalize the base URL.
            try {
                url = Utils.newURL(Utils.newURL(path), spec);
            } catch (MalformedURLException ex) {
                throw new RuntimeException(ex);
            }

            result = url.toString();
        } else {
            String entry;

            if (spec.startsWith("/")) {
                // This is an absolute entry path, so we ignore the existing
                // entry path.
                entry = canonicalize(spec);
            } else {
                // Extract the existing entry path.
                entry = path.substring(index + 1);

                if (entry.endsWith("/")) {
                    // The entry ends with '/', so we can directly append the
                    // relative entry path.
                    entry = canonicalize(entry + spec);
                } else if (entry.endsWith("/.")) {
                    // We don't want the logic below because "." is not a
                    // "true" basename.
                    entry = canonicalize(entry + '/' + spec);
                } else {
                    // Strip off the basename with a ".." path segment and
                    // append the relative entry path.
                    entry = canonicalize(entry + "/../" + spec);
                }
            }

            result = path.substring(0, index) + '!' + entry;
        }
        return result;
    }
1223186
public static String getPath(final String url, final Map<String, String> parameters) {
		return getPath(url, parameters, false);
	}
651636
public static boolean isSimonUrl(String url) {
		return url != null && url.toLowerCase().startsWith(SimonConnectionConfiguration.URL_PREFIX);
	}
575361
def url_to_path(self, url):
        
        parts = urlsplit(url)
        try:
            loader, args = self.url_map.bind(parts.netloc).match(parts.path)
            path = args.get('path')
            if loader == 'schema' and path in self.schemas:
                return path
        except HTTPException:
            return None
761308
public static boolean isJarFileURL(URL url) {
		return (URL_PROTOCOL_FILE.equals(url.getProtocol()) && //
				url.getPath().toLowerCase().endsWith(FileUtil.JAR_FILE_EXT));
	}
1135296
public static UrlBuilder parse(URL url) {
        final UrlBuilder result = new UrlBuilder();

        if (url != null) {
            final String protocol = url.getProtocol();
            if (protocol != null && !protocol.isEmpty()) {
                result.withScheme(protocol);
            }

            final String host = url.getHost();
            if (host != null && !host.isEmpty()) {
                result.withHost(host);
            }

            final int port = url.getPort();
            if (port != -1) {
                result.withPort(port);
            }

            final String path = url.getPath();
            if (path != null && !path.isEmpty()) {
                result.withPath(path);
            }

            final String query = url.getQuery();
            if (query != null && !query.isEmpty()) {
                result.withQuery(query);
            }
        }

        return result;
    }
408480
def extract(url):
    
    parts = split(url)
    if parts.scheme:
        netloc = parts.netloc
        path = parts.path
    else:
        netloc = parts.path
        path = ''
        if '/' in netloc:
            netloc, path_raw = netloc.split('/', 1)
            path = '/' + path_raw
    username, password, host, port = split_netloc(netloc)
    subdomain, domain, tld = split_host(host)
    return URL(parts.scheme, username, password, subdomain, domain, tld,
               port, path, parts.query, parts.fragment, url)
998614
function parseUrl(url) {
        if (Core.isBlank(url)) {
            return null;
        }
        var matches = url.match(httpRegex);
        if (matches === null) {
            return null;
        }
        //log.debug("matches: ", matches);
        var scheme = matches[1];
        var host = matches[3];
        var port = matches[4];
        var parts = null;
        if (!Core.isBlank(port)) {
            parts = url.split(port);
        }
        else {
            parts = url.split(host);
        }
        // make sure we use port as a number
        var portNum = Core.parseIntValue(port);
        var path = parts[1];
        if (path && _.startsWith(path, '/')) {
            path = path.slice(1, path.length);
        }
        //log.debug("parts: ", parts);
        return {
            scheme: scheme,
            host: host,
            port: portNum,
            path: path
        };
    }
26301
@Override
	public boolean apply(final URI url) {

		final String s = url.getRawPath();
		final int length = s.length();
		final boolean pathEndsWithSlash = s.charAt(length - 1) == '/';

		final char[] path = new char[length + 1 + (! pathEndsWithSlash? 1 : 0)];
		path[path.length - 1] = EXTRA_SYMBOL; // Usual suffix-array trick
		if (!pathEndsWithSlash) path[path.length - 2] = '/'; // To guarantee that each segment ends with a slash
		s.getChars(0, length, path, 0);

		// Phase 1: count slashes
		int c = 0;
		for(int i = length; i-- != 0;) if (path[i] == '/') c++;
		if (c < threshold) {
			if (ASSERTS) matches(true, s);
			return true; // No way
		}

		// Phase 2: allocate and fill start array
		final int[] start = new int[c];
		c = 0;
		for(int i = 0; i < length; i++) if (path[i] == '/') start[c++] = i;

		// Phase 3: build suffix array for path components and compute largest number of common path segments

		final int[] a = new int[c];
		for(int i = c; i-- != 0;) a[i] = i;

		IntArrays.quickSort(a, 0, c, (x,y) -> {
				if (x == y) return 0;
				int j = start[x], k = start[y];
				while(path[++j] == path[++k]);
				return path[j] - path[k];
			}
		);

		// Linear-time LCP computation, from Kasai et. al paper.
		final int[] r= new int[c];
		for(int i = c; i-- != 0;) r[a[i]] = i;

		final int[] lcp = new int[c + 1]; // Last element account for the $ element
		int h = 0;
		int p = 1;
		boolean maxNonZero = false;

		for(int i = 0; i < c; i++) {
			if (r[i] > 0) {
				int j = a[r[i] - 1];
				final int starti = start[i];
				final int startj = start[j];
				while(path[starti + p] == path[startj + p]) {
					if (path[starti + p] == '/') h++;
					p++;
				}

				lcp[r[i]] = h;
				if (h > 0) {
					maxNonZero = true;
					// Discard first common segment
					int k = 1;
					while(path[starti + k] != '/') k++;
					p -= k;
					h--;
				}
				else p = 1;
			}
		}

		if (! maxNonZero) {
			if (ASSERTS) matches(true, s);
			return true; // Not a single common prefix
		}

		if (ASSERTS) {
			final int[] lcp2 = new int[c + 1];
			for(int i = c; i-- != 1;) {
				final int starti = start[a[i - 1]];
				final int startipp = start[a[i]];

				int k = 1;
				int n = 0;
				while(path[starti + k] == path[startipp + k]) {
					if (path[starti + k] == '/') n++;
					k++;
				}

				lcp2[i] = n;
			}

			assert Arrays.equals(lcp2, lcp);
		}

		if (DEBUG) System.err.println("Path: " + Arrays.toString(path));
		if (DEBUG) System.err.println("Start: " + Arrays.toString(start));
		if (DEBUG) System.err.println("Suffixes: " + Arrays.toString(a));
		if (DEBUG) System.err.println("Common paths: " + Arrays.toString(lcp));

		// Phase 4: Simulate depth-first visit of the suffix tree

		// Simulated visit of the associated suffix tree, always by Kasai et. al.

		// A stack for left extremes and depth, initialised with -1, -1.
		final int[] ls = new int[c + 1], ds = new int[c + 1];
		/* A support array where, while visiting a node, we will store the length of the
		 * maximal arithmetic progression of ratio d among the leaves of the current
		 * node. */
		final int[] prog = new int[c];
		ls[0] = ds[0] = -1;
		p = 1;

		int llca, dlca;
		int l, d;

		for(int i = 0; i < c; i++) {
			llca = i;
			dlca = lcp[i + 1]; // Note that when i == c - 1 then lcp[i + 1] == 0.

			while(ds[p - 1] > dlca) {
				// Pop (l,d) off the stack
				l = ls[--p];
				d = ds[p];

				if (DEBUG) System.err.printf("Got triple <" + l + ", " + i + ", " + d + "\n");
				if (DEBUG) System.err.println(IntArrayList.wrap(a).subList(l, i + 1));
				// Now we have a visit interval start at L, ending at i of depth H
				if (i - l + 1 >= threshold) {
					/* Now we have a list of leaves which share a common prefix of length d.
					 * Stoye and Gusfield note that we can find an arithmetic progression of
					 * ratio d among those leaves (e.g., we can find leaves whose associated positions are
					 * i, i+d, i+2d, ..., i+(k-1)d) iff those positions
					 * are the starting points of a tandem array of length k.
					 *
					 * To do this in linear time, we exploit the fact (noted by Stoye and Gusfield)
					 * that for l <= j <= i, r[a[j] + t * d] is the position in the string of
					 * a[j] + t * d, which means that a[j] + t * d is in the set of
					 * leaves under examination (i.e., a[l..i]) iff r[a[j] + t * d]
					 * is between l and i (inclusive).
					 *
					 * To avoid testing all elements separately (which would require potentially
					 * (i - l + 1) * k tests) we use prog either to remember the length of the longest
					 * increasing progression found starting with the corresponding element of a,
					 * or to remember that an element need not being examined because it cannot lead
					 * to maximal progressions.
					 *
					 * Starting from each leaf a[j], we try to
					 * extent greedily an arithmetic progression of ratio d, and record its length
					 * in prog[j]. When examining the following elements, if following the progression
					 * we hit an element with nonzero prog, we can just sum to the current length
					 * the number found thereis and break the loop, as the maximal arithmetic
					 * progression of ratio d from our current position has been already computed.
					 */
					Arrays.fill(prog, l, i + 1, 0);
					for(int j = l; j <= i; j++) {
						if (prog[j] != 0) continue;
						int t = 1, u = a[j], k = u, pos;
						for(;;)  {
							k += d; // The next element of the progression
							if (k >= c) break;
							pos = r[k]; // Its position (in [l..i])
							if (pos < l || i < pos) break;
							else if (prog[pos] != 0) {
								if (ASSERTS) assert prog[pos] > 0 : "l="  + l + " , i=" + i + ", j=" + j + ", t=" + t + ", a=" + Arrays.toString(a) + ", prog=" + Arrays.toString(prog);
								t += prog[pos];
								break;
							}
							t++;
						}
						if (t >= threshold) {
							if (ASSERTS) matches(false, s);
							return false;
						}
						prog[j] = t;
						// We backtrack, putting -1 in all intermediate entries so we won't examine them further
						while((k -= d) != u) prog[r[k]] = -1;
					}
				}
				llca = l;

			}

			if (ds[p - 1] < dlca) {
				// Push (llca, dlca) on the stack
				ls[p] = llca;
				ds[p++] = dlca;
			}
		}

		if (ASSERTS) matches(true, s);
		return true;
	}