Refine use of substring operations

Closes gh-25445
This commit is contained in:
Juergen Hoeller
2020-08-07 14:50:44 +02:00
parent b254777744
commit ce4001dd40
15 changed files with 39 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -245,12 +245,12 @@ public class RedirectView extends AbstractUrlBasedView {
String name = matcher.group(1);
Object value = (model.containsKey(name) ? model.get(name) : uriVariables.get(name));
Assert.notNull(value, () -> "No value for URI variable '" + name + "'");
result.append(targetUrl.substring(endLastMatch, matcher.start()));
result.append(targetUrl, endLastMatch, matcher.start());
result.append(encodeUriVariable(value.toString()));
endLastMatch = matcher.end();
found = matcher.find();
}
result.append(targetUrl.substring(endLastMatch, targetUrl.length()));
result.append(targetUrl.substring(endLastMatch));
return result;
}