diff --git a/lib/src/main/java/org/tinyweb/commons/QueryUtil.java b/lib/src/main/java/org/tinyweb/commons/QueryUtil.java index eb9386f..3e8df0f 100644 --- a/lib/src/main/java/org/tinyweb/commons/QueryUtil.java +++ b/lib/src/main/java/org/tinyweb/commons/QueryUtil.java @@ -24,7 +24,8 @@ public static HashMap> queryParamsFromUrl(String rawUrl) { String[] params = decodedUrl.split("&"); for (String param : params) { String[] keyValue = param.split("="); - if (keyValue.length > 2) { + + if (keyValue.length >= 2) { String name = keyValue[0].trim(); String value = keyValue[1].trim(); diff --git a/lib/src/main/java/org/tinyweb/paths/PathUtil.java b/lib/src/main/java/org/tinyweb/paths/PathUtil.java index 605a003..1110822 100644 --- a/lib/src/main/java/org/tinyweb/paths/PathUtil.java +++ b/lib/src/main/java/org/tinyweb/paths/PathUtil.java @@ -22,14 +22,22 @@ public static PathParseResult parsePath(String rawPath) { int firstQuestionMarkIndex = rawPath.indexOf("?"); if (firstQuestionMarkIndex == -1) { - pathParseResult.pathName = URLDecoder.decode(rawPath); + try { + pathParseResult.pathName = URLDecoder.decode(rawPath, "UTF-8"); + } catch (UnsupportedEncodingException e) { + pathParseResult.pathName = rawPath; + } pathParseResult.queryParams = new HashMap<>(); return pathParseResult; } // Skips question mark character String pathName = rawPath.substring(0, firstQuestionMarkIndex); - pathParseResult.pathName = URLDecoder.decode(pathName); + try { + pathParseResult.pathName = URLDecoder.decode(pathName, "UTF-8"); + } catch (UnsupportedEncodingException e) { + pathParseResult.pathName = pathName; + } String rawQueryParams = rawPath.substring(firstQuestionMarkIndex + 1); pathParseResult.queryParams = QueryUtil.queryParamsFromUrl(rawQueryParams);