yanzhenjie / AndServer

:cherries: Web server and web framework of Android platform.
https://yanzhenjie.com/AndServer
Apache License 2.0
3.74k stars 755 forks source link

bug in PathVariables #535

Open klgec opened 8 months ago

klgec commented 8 months ago

https://github.com/yanzhenjie/AndServer/blob/23a7c15512f5a70a9ce517710a5d04c06a4d57c9/api/src/main/java/com/yanzhenjie/andserver/framework/handler/MappingHandler.java#L146

the tokenized path variables are chopped by 1 char on both ends. /hello/{test} will make tokens: "ell" and "test". this is why 1-char paths fail to even function, like: /b/a/{test}.

Fix:

if (key.startsWith("{") && key.endsWith("}"))
    key = key.substring(1, key.length() - 1);