Skip to content

Commit

Permalink
Fixes NPE in RequestRouting#canonicalize() (#1072)
Browse files Browse the repository at this point in the history
Signed-off-by: Laird Nelson <laird.nelson@oracle.com>
  • Loading branch information
ljnelson committed Sep 30, 2019
1 parent 88b44f0 commit 720ca1d
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@ public void route(BareRequest bareRequest, BareResponse bareResponse) {
}

private static String canonicalize(String p) {
String result = p;
if (p.charAt(p.length() - 1) == '/') {
result = p.substring(0, p.length() - 1);
}
if (result.isEmpty()) {
String result;
if (p == null || p.isEmpty() || p.equals("/")) {
result = "/";
} else {
int lastCharIndex = p.length() - 1;
if (p.charAt(lastCharIndex) == '/') {
result = p.substring(0, lastCharIndex);
} else {
result = p;
}
}
return result;
}
Expand Down

0 comments on commit 720ca1d

Please sign in to comment.