You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2019/04/24 08:28:54 UTC

[httpcomponents-core] 01/01: HTTPCLIENT-1986: URIBuilder#isPathEmpty method to verify if encodedPath is an empty string

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

olegk pushed a commit to branch HTTPCLIENT-1986
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit a456a8429176b8a47a88874f4f973c9630eb753c
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Wed Apr 24 10:28:25 2019 +0200

    HTTPCLIENT-1986: URIBuilder#isPathEmpty method to verify if encodedPath is an empty string
---
 httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java     | 3 ++-
 httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
index 670ce3a..bae3c23 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
@@ -550,7 +550,8 @@ public class URIBuilder {
     }
 
     public boolean isPathEmpty() {
-        return (this.pathSegments == null || this.pathSegments.isEmpty()) && this.encodedPath == null;
+        return (this.pathSegments == null || this.pathSegments.isEmpty()) &&
+                (this.encodedPath == null || this.encodedPath.isEmpty());
     }
 
     public List<String> getPathSegments() {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java b/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java
index d1f9036..3e16d9a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java
@@ -164,6 +164,12 @@ public class TestURIBuilder {
     }
 
     @Test
+    public void testEmptyPath() throws Exception {
+        final URIBuilder uribuilder = new URIBuilder("http://thathost");
+        Assert.assertTrue(uribuilder.isPathEmpty());
+    }
+
+    @Test
     public void testSetUserInfo() throws Exception {
         final URI uri = new URI("http", null, "localhost", 80, "/", "param=stuff", null);
         final URIBuilder uribuilder = new URIBuilder(uri).setUserInfo("user", "password");