Skip to content

Commit

Permalink
#35 reproduced
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 5, 2017
1 parent 7cb451d commit 3fdbe60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/io/jare/tk/TkRelay.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public Response act(final Request req) throws IOException {
if (!param.hasNext()) {
throw new HttpException(
HttpURLConnection.HTTP_BAD_REQUEST,
"parameter \"u\" is mandatory"
"Parameter \"u\" is mandatory"
);
}
final String target = param.next().trim();
if (!TkRelay.PTN.matcher(target).matches()) {
throw new HttpException(
HttpURLConnection.HTTP_BAD_REQUEST,
String.format(
"target URL \"%s\" is not compliant with RFC3986",
"Target URL \"%s\" is not compliant with RFC3986",
target
)
);
Expand All @@ -100,7 +100,7 @@ public Response act(final Request req) throws IOException {
HttpURLConnection.HTTP_BAD_REQUEST,
String.format(
// @checkstyle LineLength (1 line)
"domain \"%s\" is not registered, check your account at www.jare.io",
"Domain \"%s\" is not registered, check your account at www.jare.io",
host
)
);
Expand Down
11 changes: 9 additions & 2 deletions src/test/java/io/jare/tk/TkRelayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package io.jare.tk;

import io.jare.fake.FkBase;
import java.net.URLEncoder;
import java.util.Arrays;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -81,15 +82,21 @@ public void sendsRequestThrough() throws Exception {
@Test
public void sendsRequestThroughToHome() throws Exception {
final Take target = new TkFork(
new FkRegex("/", new TkText("it's home"))
new FkRegex("/.*", new TkText("it's home"))
);
new FtRemote(target).exec(
home -> MatcherAssert.assertThat(
new RsPrint(
new TkRelay(new FkBase()).act(
new RqFake(
Arrays.asList(
String.format("GET /?u=%s", home),
String.format(
"GET /?u=%s",
URLEncoder.encode(
home.resolve("/альфа").toASCIIString(),
"UTF-8"
)
),
"Host: localhost "
),
""
Expand Down

0 comments on commit 3fdbe60

Please sign in to comment.