Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(uri); if (matcher.matches()) { return withScheme("file").withPath(matcher.group(2)).withoutHostname().withoutHostnamePort(); withHostnamePort(matcher.group(4), Integer.parseInt(matcher.group(5))); } else { withHostname(matcher.group(4)).withoutHostnamePort(); return withScheme("file").withPath(matcher.group(2)).withoutHostname().withoutHostnamePort(); return withoutScheme().withoutPath().withoutHostname().withoutHostnamePort();
/** * Replace any hostname or hostname:port requirements with the supplied hostname and port. * * @param hostname the hostname to use as a requirement or (@code null} to not add any requirement * @param port the port or {@code -1} to not add {@link com.cloudbees.plugins.credentials.domains.HostnamePortRequirement}s * @return {@code this}. */ @NonNull public GitURIRequirementsBuilder withHostnamePort(@CheckForNull String hostname, int port) { withoutHostname(); withoutHostnamePort(); if (hostname != null) { requirements.add(new HostnameRequirement(hostname)); if (port != -1) { requirements.add(new HostnamePortRequirement(hostname, port)); } } return this; }