private void parseUrl()

in maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java [120:177]


    private void parseUrl(String url) {
        if (url.startsWith("file")) {
            setProtocol("file://");
        } else if (url.startsWith("https")) {
            setProtocol("https://");
        } else if (url.startsWith("http")) {
            setProtocol("http://");
        } else if (url.startsWith("svn+")) {
            setProtocol(url.substring(0, url.indexOf("://") + 3));
        } else if (url.startsWith("svn")) {
            setProtocol("svn://");
        }

        if (getProtocol() == null) {
            return;
        }

        String urlPath = url.substring(getProtocol().length());

        int indexAt = urlPath.indexOf('@');

        // a file:// URL may contain userinfo according to RFC 8089, but our implementation is broken
        // extract user information, broken see SCM-909
        if (indexAt > 0 && !getProtocol().startsWith("svn+") && !getProtocol().equals("file://")) {
            String userPassword = urlPath.substring(0, indexAt);
            if (userPassword.indexOf(':') < 0) {
                setUser(userPassword);
            } else {
                setUser(userPassword.substring(0, userPassword.indexOf(':')));
                setPassword(userPassword.substring(userPassword.indexOf(':') + 1));
            }

            urlPath = urlPath.substring(indexAt + 1);

            this.url = getProtocol() + urlPath;
        } else {
            this.url = getProtocol() + urlPath;
        }

        if (!"file://".equals(getProtocol())) {
            int indexSlash = urlPath.indexOf('/');

            String hostPort = urlPath;

            if (indexSlash > 0) {
                hostPort = urlPath.substring(0, indexSlash);
            }

            int indexColon = hostPort.indexOf(':');

            if (indexColon > 0) {
                setHost(hostPort.substring(0, indexColon));
                setPort(Integer.parseInt(hostPort.substring(indexColon + 1)));
            } else {
                setHost(hostPort);
            }
        }
    }