This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch WAGON-569
in repository https://gitbox.apache.org/repos/asf/maven-wagon.git


The following commit(s) were added to refs/heads/WAGON-569 by this push:
     new 130ac45  Split encodeURLToString() in two methods
130ac45 is described below

commit 130ac4599c8d65041e5784c2db19ed117b8b2d35
Author: Michael Osipov <[email protected]>
AuthorDate: Tue Oct 29 17:58:10 2019 +0100

    Split encodeURLToString() in two methods
---
 .../maven/wagon/shared/http/EncodingUtil.java      | 27 ++++++++++++++++------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git 
a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
 
b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
index 1d74280..67f5e5f 100644
--- 
a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
+++ 
b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
@@ -81,20 +81,33 @@ public class EncodingUtil
     }
 
     /**
-     * Parses and returns an encoded version of the given URL string alongside 
the given paths.
+     * Parses and returns an encoded version of the given URL string alongside 
the given path.
      *
      * @param baseUrl Base URL to use when constructing the final URL. This 
has to be a valid URL already.
-     * @param paths   Additional unencoded path(s) to append at the end of the 
base path.
-     * @return Composed URL (base + paths) already encoded, separating the 
individual path components by "/".
+     * @param path Additional unencoded path to append at the end of the base 
path.
+     * @return Composed URL (base + path) already encoded, separating the 
individual path segments by "/".
      * @since TODO
      */
-    public static String encodeURLToString( String baseUrl, String... paths )
+    public static String encodeURLToString( String baseUrl, String path )
+    {
+        String[] pathSegments = path == null ? new String[0] : path.split( "/" 
);
+
+        return encodeURLToString( baseUrl, pathSegments );
+    }
+
+    /**
+     * Parses and returns an encoded version of the given URL string alongside 
the given path segments.
+     *
+     * @param baseUrl Base URL to use when constructing the final URL. This 
has to be a valid URL already.
+     * @param pathSegments Additional unencoded path segments to append at the 
end of the base path.
+     * @return Composed URL (base + path) already encoded, separating the 
individual path segments by "/".
+     * @since TODO
+     */
+    public static String encodeURLToString( String baseUrl, String... 
pathSegments )
     {
         StringBuilder url = new StringBuilder( baseUrl );
 
-        String[] segments = paths == null ? //
-            new String[0] : //
-            paths.length == 1 ? paths[0].split( "/" ) : paths;
+        String[] segments = pathSegments == null ? new String[0] : 
pathSegments;
 
         String path = URLEncodedUtils.formatSegments( segments );
 

Reply via email to