diff --git a/src/main/java/io/jare/tk/Destination.java b/src/main/java/io/jare/tk/Destination.java index 478ed5d..aa4020a 100644 --- a/src/main/java/io/jare/tk/Destination.java +++ b/src/main/java/io/jare/tk/Destination.java @@ -86,6 +86,9 @@ public String path() throws HttpException { if (this.uri.getQuery() != null) { path.append('?').append(this.uri.getQuery()); } + if (this.uri.getFragment() != null) { + path.append('#').append(this.uri.getFragment()); + } return path.toString(); } diff --git a/src/test/java/io/jare/tk/DestinationTest.java b/src/test/java/io/jare/tk/DestinationTest.java index 9be8bd9..e67cb34 100644 --- a/src/test/java/io/jare/tk/DestinationTest.java +++ b/src/test/java/io/jare/tk/DestinationTest.java @@ -72,4 +72,16 @@ public void buildsPathWithParams() throws Exception { ); } + /** + * Destination can build path with fragment. + * @throws Exception If some problem inside + */ + @Test + public void buildsPathWithFragment() throws Exception { + MatcherAssert.assertThat( + new Destination(new URI("http://www.google.com/a?x=1#t")).path(), + Matchers.equalTo("/a?x=1#t") + ); + } + }