You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2020/07/26 15:22:07 UTC
[commons-validator] branch master updated: Show URI parsing details
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-validator.git
The following commit(s) were added to refs/heads/master by this push:
new ba33652 Show URI parsing details
ba33652 is described below
commit ba3365215e2d8df99b8dc9ba324ade43b8015f3c
Author: Sebb <se...@apache.org>
AuthorDate: Sun Jul 26 16:21:59 2020 +0100
Show URI parsing details
---
.../commons/validator/routines/UrlValidator.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/main/java/org/apache/commons/validator/routines/UrlValidator.java b/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
index b26d958..f28be2d 100644
--- a/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
+++ b/src/main/java/org/apache/commons/validator/routines/UrlValidator.java
@@ -547,6 +547,25 @@ public class UrlValidator implements Serializable {
public static void main(String[] args) {
UrlValidator val = new UrlValidator(new String[] { "file", "http", "https" }, UrlValidator.ALLOW_LOCAL_URLS);
for(String arg: args) {
+ try {
+ URI uri = new URI(arg);
+ uri = uri.normalize();
+ System.out.printf("URI scheme: %s%n", uri.getScheme());
+ System.out.printf("URI auth: %s%n", uri.getAuthority());
+ System.out.printf("URI raw auth: %s%n", uri.getRawAuthority());
+ System.out.printf("URI userInfo: %s%n", uri.getUserInfo());
+ System.out.printf("URI raw userInfo: %s%n", uri.getRawUserInfo());
+ System.out.printf("URI host: %s%n", uri.getHost());
+ System.out.printf("URI port: %s%n", uri.getPort());
+ System.out.printf("URI path: %s%n", uri.getPath());
+ System.out.printf("URI raw path: %s%n", uri.getRawPath());
+ System.out.printf("URI query: %s%n", uri.getQuery());
+ System.out.printf("URI raw query: %s%n", uri.getRawQuery());
+ System.out.printf("URI fragment: %s%n", uri.getFragment());
+ System.out.printf("URI raw fragment: %s%n", uri.getRawFragment());
+ } catch (URISyntaxException e) {
+ System.out.println(e.getMessage());
+ }
Matcher m = val.matchURL(arg);
if (m.matches()) {
System.out.printf("%s has %d parts%n",arg,m.groupCount());