LinkExtractor getURI(String target) does not resolve correctly when baseUri is 
provided
---------------------------------------------------------------------------------------

                 Key: DROIDS-115
                 URL: https://issues.apache.org/jira/browse/DROIDS-115
             Project: Droids
          Issue Type: Bug
          Components: core
            Reporter: Paul Rogalinski


the getURI() Method won't resolve the URL correctly if a baseUri is provided 
without the trailing slash *and* the relative url to be resolved does not start 
with "/". Under that circumstances it will resolve to: 
http://example.comRelativeUrl. 

proposed Patch:

        private URI getURI(String target)       {
                target = target.replaceAll("\\s", "%20");
                try     {
                        if (!target.toLowerCase().startsWith("javascript")&& 
!target.contains(":/")) {
                                return 
baseUri.resolve((baseUri.toString().endsWith(baseUri.getHost()) && 
!target.startsWith("/") ? "/" : "") + target.split("#")[0]);
                        }
                        else if 
(!target.toLowerCase().startsWith("javascript")) {
                                return new URI(target.split("#")[0]);
                        }
                }
                catch (Exception e)     {
                        log.debug("URI not valid: " + target);
                }
                return null;
        }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to