mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8294626: Improve URL protocol lower casing
Reviewed-by: dfuchs
This commit is contained in:
parent
052a924985
commit
3efbd5f0fa
3 changed files with 22 additions and 11 deletions
|
@ -49,8 +49,14 @@ public class URLUtil {
|
|||
|
||||
String protocol = url.getProtocol();
|
||||
if (protocol != null) {
|
||||
/* protocol is compared case-insensitive, so convert to lowercase */
|
||||
protocol = protocol.toLowerCase();
|
||||
/* protocol is compared case-insensitive, so convert to lowercase
|
||||
* if needed. URL will store from lower-cased String literals for
|
||||
* built-in protocols, so avoid calling toLowerCase for these and
|
||||
* use identity tests for speed
|
||||
*/
|
||||
if (protocol != "file" && protocol != "jrt" && protocol != "jar") {
|
||||
protocol = protocol.toLowerCase();
|
||||
}
|
||||
strForm.append(protocol);
|
||||
strForm.append("://");
|
||||
}
|
||||
|
@ -58,8 +64,9 @@ public class URLUtil {
|
|||
String host = url.getHost();
|
||||
if (host != null) {
|
||||
/* host is compared case-insensitive, so convert to lowercase */
|
||||
host = host.toLowerCase();
|
||||
strForm.append(host);
|
||||
if (!host.isEmpty()) {
|
||||
strForm.append(host.toLowerCase());
|
||||
}
|
||||
|
||||
int port = url.getPort();
|
||||
if (port == -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue