From: <bra...@us...> - 2009-10-15 22:51:36
|
Revision: 2809 http://archive-access.svn.sourceforge.net/archive-access/?rev=2809&view=rev Author: bradtofel Date: 2009-10-15 22:51:23 +0000 (Thu, 15 Oct 2009) Log Message: ----------- REFACTOR: moved parsing of path from a URL String here... it should be further refactored into URL, or UURI... Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/url/UrlOperations.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/url/UrlOperations.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/url/UrlOperations.java 2009-10-15 22:44:10 UTC (rev 2808) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/url/UrlOperations.java 2009-10-15 22:51:23 UTC (rev 2809) @@ -22,6 +22,9 @@ public final static String FTP_SCHEME = "ftp://"; public final static String MMS_SCHEME = "mms://"; public final static String RTSP_SCHEME = "rtsp://"; + + public final static String DEFAULT_SCHEME = HTTP_SCHEME; + // go brewster public final static String WAIS_SCHEME = "wais://"; @@ -132,6 +135,25 @@ } return -1; } + + public static String getURLPath(String url) { + int portIdx = url.indexOf(UrlOperations.PORT_SEPARATOR); + int pathIdx = url.indexOf(UrlOperations.PATH_START); + if(portIdx == -1 && pathIdx == -1) { + return ""; + } + if(portIdx == -1) { + return url.substring(pathIdx); + } + if(pathIdx == -1) { + return url.substring(portIdx); + } + if(pathIdx > portIdx) { + return url.substring(portIdx); + } else { + return url.substring(pathIdx); + } + } public static String urlToHost(String url) { if(url.startsWith("dns:")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |