protected URL createUrl()

in src/main/java/org/apache/commons/mail/resolver/DataSourceUrlResolver.java [109:131]


    protected URL createUrl(final String resourceLocation) throws MalformedURLException
    {
        // if we get an non-existing base url than the resource can
        // be directly used to create an URL
        if (baseUrl == null)
        {
            return new URL(resourceLocation);
        }

        // if we get an non-existing location what we shall do?
        if (resourceLocation == null || resourceLocation.isEmpty())
        {
            throw new IllegalArgumentException("No resource defined");
        }

        // if we get a stand-alone resource than ignore the base url
        if (isFileUrl(resourceLocation) || isHttpUrl(resourceLocation))
        {
            return new URL(resourceLocation);
        }

        return new URL(getBaseUrl(), resourceLocation.replace("&", "&"));
    }