Skip to content

Commit 0f53641

Browse files
authored
Merge pull request #47395 from ia3andy/issue-47384
Optimise path decoding in RoutingUtils
2 parents 0061772 + 537c43c commit 0f53641

File tree

1 file changed

+7
-4
lines changed
  • extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime

1 file changed

+7
-4
lines changed

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/RoutingUtils.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.quarkus.vertx.http.runtime;
22

3-
import java.net.URI;
43
import java.util.Set;
54

65
import io.vertx.core.http.HttpHeaders;
76
import io.vertx.core.http.impl.MimeMapping;
7+
import io.vertx.core.net.impl.URIDecoder;
88
import io.vertx.ext.web.RoutingContext;
99
import io.vertx.ext.web.handler.StaticHandler;
1010

@@ -17,18 +17,21 @@ private RoutingUtils() throws IllegalAccessException {
1717
/**
1818
* Get the normalized and decoded path:
1919
* - normalize based on RFC3986
20-
* - convert % encoded characters to their non encoded form (using {@link java.net.URI})
20+
* - convert % encoded characters to their non encoded form (using {@link URIDecoder#decodeURIComponent})
2121
* - invalid if the path contains '?' (query section of the path)
2222
*
2323
* @param ctx the RoutingContext
2424
* @return the normalized and decoded path or null if not valid
2525
*/
2626
public static String getNormalizedAndDecodedPath(RoutingContext ctx) {
2727
String normalizedPath = ctx.normalizedPath();
28-
if (normalizedPath.contains("?")) {
28+
if (normalizedPath.indexOf('?') != -1) {
2929
return null;
3030
}
31-
return URI.create(normalizedPath).getPath();
31+
if (normalizedPath.indexOf('%') == -1) {
32+
return normalizedPath;
33+
}
34+
return URIDecoder.decodeURIComponent(normalizedPath);
3235
}
3336

3437
/**

0 commit comments

Comments
 (0)