Only add / to uri if really needed.

Motivation:

We not need to include the start index in the check. See https://github.com/netty/netty/pull/6924#discussion_r125263918

Modifications:

Change <= to <

Result:

More correct code.
This commit is contained in:
Norman Maurer 2017-07-10 14:42:01 +02:00
parent e6a399a778
commit f1e14d0cb2

View File

@ -56,11 +56,11 @@ public class HttpRequestEncoder extends HttpObjectEncoder<HttpRequest> {
// See https://github.com/netty/netty/issues/2732
int index = uri.indexOf(QUESTION_MARK, start);
if (index == -1) {
if (uri.lastIndexOf(SLASH) <= start) {
if (uri.lastIndexOf(SLASH) < start) {
needSlash = true;
}
} else {
if (uri.lastIndexOf(SLASH, index) <= start) {
if (uri.lastIndexOf(SLASH, index) < start) {
uriCharSequence = new StringBuilder(uri).insert(index, SLASH);
}
}