diff --git a/QRCoder/PayloadGenerator.cs b/QRCoder/PayloadGenerator.cs index 85d2a49f..7c7c83f8 100644 --- a/QRCoder/PayloadGenerator.cs +++ b/QRCoder/PayloadGenerator.cs @@ -312,7 +312,7 @@ public class Url : Payload private readonly string url; /// - /// Generates a link. If not given, http/https protocol will be added. + /// Generates a link. If the protocol is not specified, the http protocol will be added. /// /// Link url target public Url(string url) @@ -322,7 +322,7 @@ public Url(string url) public override string ToString() { - return (!this.url.StartsWith("http") ? "http://" + this.url : this.url); + return (!this.url.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? "http://" + this.url : this.url); } } diff --git a/QRCoderTests/PayloadGeneratorTests.cs b/QRCoderTests/PayloadGeneratorTests.cs index f4ecc05d..e3beda3c 100644 --- a/QRCoderTests/PayloadGeneratorTests.cs +++ b/QRCoderTests/PayloadGeneratorTests.cs @@ -757,6 +757,18 @@ public void url_should_build_https() } + [Fact] + [Category("PayloadGenerator/Url")] + public void url_should_build_https_all_caps() + { + var url = "HTTPS://CODE-BUDE.NET"; + + var generator = new PayloadGenerator.Url(url); + + generator.ToString().ShouldBe("HTTPS://CODE-BUDE.NET"); + } + + [Fact] [Category("PayloadGenerator/Url")] public void url_should_add_http()