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

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


The following commit(s) were added to refs/heads/master by this push:
     new c23380c6 Deprecate URL parsing methods in PathUtils in favor of JDK's 
URI class (#171)
c23380c6 is described below

commit c23380c695879ecf315bd548247999819a811c71
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Sat Jun 14 10:09:27 2025 +0000

    Deprecate URL parsing methods in PathUtils in favor of JDK's URI class 
(#171)
---
 .../java/org/apache/maven/wagon/PathUtils.java     | 24 ++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git 
a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java 
b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
index 9c05eba4..5f7e61d7 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
@@ -22,7 +22,12 @@
 import java.util.StringTokenizer;
 
 /**
- * Various path (URL) manipulation routines
+ * Various path (URL) manipulation routines. Standard JDK methods in
+ * java.net.URI and java.nio.file.Path should be used instead.
+ * It's not always a direct one-to-one replacement. For instance,
+ * a PathUtils method might return an empty string in a case where the
+ * corresponding JDK method returns null. However, all logic in this
+ * class has been present in the JDK since Java 1.4.
  *
  * @author <a href="michal.mac...@dimatics.com">Michal Maczka</a>
  *
@@ -113,7 +118,9 @@ private static String[] split(final String str, final 
String separator, final in
      *
      * @param url the url
      * @return the host name
+     * @deprecated replace with {@code new URI(url).getHost()}
      */
+    @Deprecated
     public static String host(final String url) {
         if (url == null || url.length() == 0) {
             return "localhost";
@@ -192,7 +199,9 @@ private static int endOfHostPosition(String host, int pos) {
      *
      * @param url the url
      * @return the host name
+     * @deprecated replace with {@code new URI(url).getScheme()}
      */
+    @Deprecated
     public static String protocol(final String url) {
         final int pos = url.indexOf(":");
 
@@ -205,7 +214,9 @@ public static String protocol(final String url) {
     /**
      * @param url
      * @return the port or {@link WagonConstants#UNKNOWN_PORT} if not existent
+     * @deprecated replace with {@code new URI(url).getPort()}
      */
+    @Deprecated
     public static int port(String url) {
 
         final String protocol = PathUtils.protocol(url);
@@ -260,8 +271,9 @@ public static int port(String url) {
      *
      * @param url the repository URL
      * @return the basedir of the repository
-     * @todo need to URL decode for spaces?
+     * @deprecated replace with {@code new URI(url).getPath()}
      */
+    @Deprecated
     public static String basedir(String url) {
         String protocol = PathUtils.protocol(url);
 
@@ -369,6 +381,10 @@ private static String decode(String url) {
         return decoded;
     }
 
+    /**
+     * @deprecated replace with {@code new URI(url).getUserInfo()}
+     */
+    @Deprecated
     public static String user(String url) {
         String host = authorization(url);
         int index = host.indexOf('@');
@@ -384,6 +400,10 @@ public static String user(String url) {
         return null;
     }
 
+    /**
+     * @deprecated do not store passwords in URLs
+     */
+    @Deprecated
     public static String password(String url) {
         String host = authorization(url);
         int index = host.indexOf('@');

Reply via email to