ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martijn Kruithof <mart...@kruithof.xs4all.nl>
Subject Re: cvs commit: ant/src/main/org/apache/tools/ant/launch Locator.java
Date Sat, 03 Apr 2004 18:42:23 GMT
mbenson@apache.org wrote:

>  
>  1.12      +12 -7     ant/src/main/org/apache/tools/ant/launch/Locator.java
>  
>  Index: Locator.java
>  ===================================================================
>  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/launch/Locator.java,v
>  retrieving revision 1.11
>  retrieving revision 1.12
>  diff -u -r1.11 -r1.12
>  --- Locator.java	9 Mar 2004 16:48:03 -0000	1.11
>  +++ Locator.java	2 Apr 2004 20:20:43 -0000	1.12
>  @@ -101,13 +101,18 @@
>        * @since Ant 1.6
>        */
>       public static String fromURI(String uri) {
>  -        if (!uri.startsWith("file:")) {
>  -            throw new IllegalArgumentException("Can only handle file: URIs");
>  -        }
>  -        if (uri.startsWith("file://")) {
>  -            uri = uri.substring(7);
>  -        } else {
>  -            uri = uri.substring(5);
>  +        try {
>  +            URL url = new URL(uri);
>  +            if (!("file".equals(url.getProtocol()))) {
>  +                throw new IllegalArgumentException("Can only handle file: URIs");
>  +            }
>  +            StringBuffer buf = new StringBuffer(url.getHost());
>  +            if (buf.length() > 0) {
>  +                buf.insert(0, "//");
>  +            }
>  +            buf.append(url.getPath());
>  +            uri = buf.toString();
>  +        } catch (MalformedURLException emYouEarlEx) {
>           }
>   
>           uri = uri.replace('/', File.separatorChar);
>  
>  
>
This is funny, If the URL isn't a file URL we throw an 
IllegalArgumentException, but if the URL isn't a valid URL at all we 
just continue? (Without removing the file:(//) which could have been in 
front, which would have been removed before?)



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message