public static URL createURL()

in src/main/java/org/apache/nifi/processor/util/URLValidator.java [80:99]


    public static URL createURL(final String url) throws MalformedURLException {
        final Matcher matcher = URI_PATTERN.matcher(url);
        if (matcher.matches()) {
            final String scheme = matcher.group(2);
            final String userInfo = matcher.group(5);
            final String host = matcher.group(6);
            final String port = matcher.group(8);
            final String path = matcher.group(9);
            final String query = matcher.group(11);
            final String fragment = matcher.group(13);

            try {
                return new URI(scheme, userInfo, host, port != null ? Integer.parseInt(port) : -1, path, query, fragment).toURL();
            } catch (final URISyntaxException e) {
                throw new MalformedURLException("Unable to create URL from " + url  + ": " + e.getMessage());
            }
        } else {
            throw new MalformedURLException(url + " is not a valid URL");
        }
    }