From ebc88956f910b366b723335a6a918b6e93c159c7 Mon Sep 17 00:00:00 2001 From: janakmulani Date: Thu, 14 Dec 2023 20:21:46 +0530 Subject: [PATCH] In UrlKey make hostname case insensitive --- core/src/main/java/net/sourceforge/jnlp/util/UrlKey.java | 2 +- core/src/test/java/net/sourceforge/jnlp/util/UrlKeyTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/net/sourceforge/jnlp/util/UrlKey.java b/core/src/main/java/net/sourceforge/jnlp/util/UrlKey.java index 4f0a485fe..c718aeed2 100644 --- a/core/src/main/java/net/sourceforge/jnlp/util/UrlKey.java +++ b/core/src/main/java/net/sourceforge/jnlp/util/UrlKey.java @@ -17,7 +17,7 @@ public class UrlKey { public UrlKey(final URL url) { this.url = url; this.protocol = url.getProtocol() != null ? url.getProtocol().toLowerCase(Locale.ENGLISH) : null; - this.host = url.getHost(); + this.host = url.getHost() != null ? url.getHost().toLowerCase(Locale.ENGLISH) : null; this.port = url.getPort(); this.file = url.getFile(); this.ref = url.getRef(); diff --git a/core/src/test/java/net/sourceforge/jnlp/util/UrlKeyTest.java b/core/src/test/java/net/sourceforge/jnlp/util/UrlKeyTest.java index 3670ef0bf..9dd9c711f 100644 --- a/core/src/test/java/net/sourceforge/jnlp/util/UrlKeyTest.java +++ b/core/src/test/java/net/sourceforge/jnlp/util/UrlKeyTest.java @@ -13,6 +13,7 @@ public void testEqualsHttp() throws Exception { URL url1 = new URL("http://www.example.com:80/index.html?a=b#3"); List urlList = Arrays.asList( new URL("http://www.example.com/index.html?a=b#3"), + new URL("http://www.Example.Com/index.html?a=b#3"), new URL("Http://www.example.com/index.html?a=b#3"), new URL("http://www.example.com:80/index.html?a=b#3")); @@ -29,7 +30,7 @@ public void testEqualsHttp() throws Exception { public void testNotEqualsHttp() throws Exception { URL url1 = new URL("http://www.example.com:80/index.html?a=b#3"); List urlList = Arrays.asList( - new URL("http://www.Example.com:80/index.html?a=b#3"), + new URL("http://www.example.org:80/index.html?a=b#3"), new URL("http://www.example.com:80/index2.html?a=b#3"), new URL("http://www.example.com:80/index.html#3"), new URL("https://www.example.com:80/index.html?a=b#3"),