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:54:11 UTC
[httpcomponents-core] branch master updated: 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 master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
The following commit(s) were added to refs/heads/master by this push:
new d245e2e HTTPCLIENT-1986: URIBuilder#isPathEmpty method to verify if encodedPath is an empty string
new 2ae0e1d Merge branch 'HTTPCLIENT-1986'
d245e2e is described below
commit d245e2edb435921e5a48d97e54389c6348b27c21
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");