Skip to content

Commit

Permalink
#8 Destination fixed to respect fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Apr 17, 2016
1 parent dc5e4dd commit c22c880
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/io/jare/tk/Destination.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/java/io/jare/tk/DestinationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
}

}

0 comments on commit c22c880

Please sign in to comment.