From 4e88511005796138b3a7a9b8e63839f7a4fe84cc Mon Sep 17 00:00:00 2001 From: Michael Haren Date: Mon, 27 Feb 2023 12:48:47 -0500 Subject: [PATCH 1/2] url payload generator should detect all-caps protocol --- QRCoder/PayloadGenerator.cs | 4 ++-- QRCoderTests/PayloadGeneratorTests.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/QRCoder/PayloadGenerator.cs b/QRCoder/PayloadGenerator.cs index 6275e5be..4beafa1e 100644 --- a/QRCoder/PayloadGenerator.cs +++ b/QRCoder/PayloadGenerator.cs @@ -311,7 +311,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 protocol not given, http protocol will be added. /// /// Link url target public Url(string url) @@ -321,7 +321,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 f4406bb7..28cfb6b2 100644 --- a/QRCoderTests/PayloadGeneratorTests.cs +++ b/QRCoderTests/PayloadGeneratorTests.cs @@ -744,6 +744,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() From 50999a941fe30936bf4ae74c595cdda8066dcfe1 Mon Sep 17 00:00:00 2001 From: Michael H Date: Mon, 8 Apr 2024 10:53:28 -0400 Subject: [PATCH 2/2] Update QRCoder/PayloadGenerator.cs Co-authored-by: Shane Krueger --- QRCoder/PayloadGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QRCoder/PayloadGenerator.cs b/QRCoder/PayloadGenerator.cs index 4beafa1e..0b640d7a 100644 --- a/QRCoder/PayloadGenerator.cs +++ b/QRCoder/PayloadGenerator.cs @@ -311,7 +311,7 @@ public class Url : Payload private readonly string url; /// - /// Generates a link. If protocol not given, http 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)