|
|
@ -75,13 +75,13 @@ public class URIish implements Serializable { |
|
|
|
* capturing groups: the first containing the user and the second containing |
|
|
|
* capturing groups: the first containing the user and the second containing |
|
|
|
* the password |
|
|
|
* the password |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final String OPT_USER_PWD_P = "(?:([^/:@]+)(?::([^/]+))?@)?"; |
|
|
|
private static final String OPT_USER_PWD_P = "(?:([^\\\\/:@]+)(?::([^\\\\/]+))?@)?"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Part of a pattern which matches the host part of URIs. Defines one |
|
|
|
* Part of a pattern which matches the host part of URIs. Defines one |
|
|
|
* capturing group containing the host name. |
|
|
|
* capturing group containing the host name. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final String HOST_P = "([^/:]+)"; |
|
|
|
private static final String HOST_P = "([^\\\\/:]+)"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Part of a pattern which matches the optional port part of URIs. Defines |
|
|
|
* Part of a pattern which matches the optional port part of URIs. Defines |
|
|
@ -93,7 +93,7 @@ public class URIish implements Serializable { |
|
|
|
* Part of a pattern which matches the ~username part (e.g. /~root in |
|
|
|
* Part of a pattern which matches the ~username part (e.g. /~root in |
|
|
|
* git://host.xyz/~root/a.git) of URIs. Defines no capturing group.
|
|
|
|
* git://host.xyz/~root/a.git) of URIs. Defines no capturing group.
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final String USER_HOME_P = "(?:/~(?:[^/]+))"; |
|
|
|
private static final String USER_HOME_P = "(?:/~(?:[^\\\\/]+))"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Part of a pattern which matches the optional drive letter in paths (e.g. |
|
|
|
* Part of a pattern which matches the optional drive letter in paths (e.g. |
|
|
@ -105,13 +105,13 @@ public class URIish implements Serializable { |
|
|
|
* Part of a pattern which matches a relative path. Relative paths don't |
|
|
|
* Part of a pattern which matches a relative path. Relative paths don't |
|
|
|
* start with slash or drive letters. Defines no capturing group. |
|
|
|
* start with slash or drive letters. Defines no capturing group. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final String RELATIVE_PATH_P = "(?:(?:[^/]+/)*[^/]+/?)"; |
|
|
|
private static final String RELATIVE_PATH_P = "(?:(?:[^\\\\/]+[\\\\/])*[^\\\\/]+[\\\\/]?)"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Part of a pattern which matches a relative or absolute path. Defines no |
|
|
|
* Part of a pattern which matches a relative or absolute path. Defines no |
|
|
|
* capturing group. |
|
|
|
* capturing group. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final String PATH_P = "(" + OPT_DRIVE_LETTER_P + "/?" |
|
|
|
private static final String PATH_P = "(" + OPT_DRIVE_LETTER_P + "[\\\\/]?" |
|
|
|
+ RELATIVE_PATH_P + ")"; |
|
|
|
+ RELATIVE_PATH_P + ")"; |
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
private static final long serialVersionUID = 1L; |
|
|
@ -129,7 +129,7 @@ public class URIish implements Serializable { |
|
|
|
+ OPT_PORT_P //
|
|
|
|
+ OPT_PORT_P //
|
|
|
|
+ "(" // open a catpuring group the the user-home-dir part
|
|
|
|
+ "(" // open a catpuring group the the user-home-dir part
|
|
|
|
+ (USER_HOME_P + "?") //
|
|
|
|
+ (USER_HOME_P + "?") //
|
|
|
|
+ "/)" //
|
|
|
|
+ "[\\\\/])" //
|
|
|
|
+ ")?" // close the optional group containing hostname
|
|
|
|
+ ")?" // close the optional group containing hostname
|
|
|
|
+ "(.+)?" //
|
|
|
|
+ "(.+)?" //
|
|
|
|
+ "$"); |
|
|
|
+ "$"); |
|
|
@ -139,7 +139,7 @@ public class URIish implements Serializable { |
|
|
|
* path (maybe even containing windows drive-letters) or a relative path. |
|
|
|
* path (maybe even containing windows drive-letters) or a relative path. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final Pattern LOCAL_FILE = Pattern.compile("^" //
|
|
|
|
private static final Pattern LOCAL_FILE = Pattern.compile("^" //
|
|
|
|
+ "(/?" + PATH_P + ")" //
|
|
|
|
+ "([\\\\/]?" + PATH_P + ")" //
|
|
|
|
+ "$"); |
|
|
|
+ "$"); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -148,7 +148,7 @@ public class URIish implements Serializable { |
|
|
|
* separator, but java.io.File.toURI() constructs those URIs. |
|
|
|
* separator, but java.io.File.toURI() constructs those URIs. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final Pattern SINGLE_SLASH_FILE_URI = Pattern.compile("^" //
|
|
|
|
private static final Pattern SINGLE_SLASH_FILE_URI = Pattern.compile("^" //
|
|
|
|
+ "(file):(/(?!/)" //
|
|
|
|
+ "(file):([\\\\/](?![\\\\/])" //
|
|
|
|
+ PATH_P //
|
|
|
|
+ PATH_P //
|
|
|
|
+ ")$"); |
|
|
|
+ ")$"); |
|
|
|
|
|
|
|
|
|
|
@ -159,7 +159,7 @@ public class URIish implements Serializable { |
|
|
|
+ OPT_USER_PWD_P //
|
|
|
|
+ OPT_USER_PWD_P //
|
|
|
|
+ HOST_P //
|
|
|
|
+ HOST_P //
|
|
|
|
+ ":(" //
|
|
|
|
+ ":(" //
|
|
|
|
+ ("(?:" + USER_HOME_P + "/)?") //
|
|
|
|
+ ("(?:" + USER_HOME_P + "[\\\\/])?") //
|
|
|
|
+ RELATIVE_PATH_P //
|
|
|
|
+ RELATIVE_PATH_P //
|
|
|
|
+ ")$"); |
|
|
|
+ ")$"); |
|
|
|
|
|
|
|
|
|
|
@ -168,9 +168,9 @@ public class URIish implements Serializable { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final Pattern ABSOLUTE_SCP_URI = Pattern.compile("^" //
|
|
|
|
private static final Pattern ABSOLUTE_SCP_URI = Pattern.compile("^" //
|
|
|
|
+ OPT_USER_PWD_P //
|
|
|
|
+ OPT_USER_PWD_P //
|
|
|
|
+ "([^/:]{2,})" //
|
|
|
|
+ "([^\\\\/:]{2,})" //
|
|
|
|
+ ":(" //
|
|
|
|
+ ":(" //
|
|
|
|
+ "/" + RELATIVE_PATH_P //
|
|
|
|
+ "[\\\\/]" + RELATIVE_PATH_P //
|
|
|
|
+ ")$"); |
|
|
|
+ ")$"); |
|
|
|
|
|
|
|
|
|
|
|
private String scheme; |
|
|
|
private String scheme; |
|
|
@ -192,7 +192,6 @@ public class URIish implements Serializable { |
|
|
|
* @throws URISyntaxException |
|
|
|
* @throws URISyntaxException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public URIish(String s) throws URISyntaxException { |
|
|
|
public URIish(String s) throws URISyntaxException { |
|
|
|
s = s.replace('\\', '/'); |
|
|
|
|
|
|
|
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s); |
|
|
|
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s); |
|
|
|
if (matcher.matches()) { |
|
|
|
if (matcher.matches()) { |
|
|
|
scheme = matcher.group(1); |
|
|
|
scheme = matcher.group(1); |
|
|
|