Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit 0990de3

Browse files
committed
Get rid of %E2%80%8B fix jooby-project#503
1 parent d056c44 commit 0990de3

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.jooby.issues;
2+
3+
import org.jooby.test.ServerFeature;
4+
import org.junit.Test;
5+
6+
import com.typesafe.config.ConfigFactory;
7+
import com.typesafe.config.ConfigValueFactory;
8+
9+
public class Issue503 extends ServerFeature {
10+
11+
{
12+
use(ConfigFactory.empty().withValue("application.path", ConfigValueFactory.fromAnyRef("/503")));
13+
14+
get("/", () -> "503");
15+
16+
err((req, rsp, x) -> {
17+
rsp.send(req.path(true));
18+
});
19+
}
20+
21+
@Test
22+
public void shouldNotSeeOddCharacters() throws Exception {
23+
request()
24+
.get("/")
25+
.expect(404)
26+
.expect("/");
27+
28+
request()
29+
.get("/foo")
30+
.expect(404)
31+
.expect("/foo");
32+
}
33+
34+
}

jooby/src/main/java/org/jooby/Request.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ default String path() {
437437
*/
438438
default String path(final boolean escape) {
439439
String path = route().path();
440-
return escape ? UrlEscapers.urlFragmentEscaper().escape(path) : path;
440+
return escape? UrlEscapers.urlFragmentEscaper().escape(path) : path;
441441
}
442442

443443
/**

jooby/src/main/java/org/jooby/Route.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,8 @@ default void next(final Request req, final Response rsp) throws Throwable {
20892089
Key<Set<Route.Definition>> KEY = Key.get(new TypeLiteral<Set<Route.Definition>>() {
20902090
});
20912091

2092+
char OUT_OF_PATH = '\u200B';
2093+
20922094
String GET = "GET";
20932095

20942096
String POST = "POST";

jooby/src/main/java/org/jooby/internal/HttpHandlerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ private static Function<String, String> rootpath(final String applicationPath) {
524524
return p.substring(applicationPath.length());
525525
} else {
526526
// mark as failure
527-
return p + '\u200B';
527+
return p + Route.OUT_OF_PATH;
528528
}
529529
};
530530
}

jooby/src/main/java/org/jooby/internal/RouteImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ public RouteImpl(final Filter filter, final Definition route, final String metho
9797
this.route = route;
9898
this.method = method;
9999
this.produces = produces;
100-
this.path = path;
101100
this.vars = vars;
102101
this.source = source;
102+
/** Clean up out of path char. */
103+
if (path.charAt(path.length() - 1) == OUT_OF_PATH) {
104+
this.path = path.substring(0, path.length() - 1);
105+
} else {
106+
this.path = path;
107+
}
103108
}
104109

105110
@Override

0 commit comments

Comments
 (0)