Skip to content

Commit 4e88511

Browse files
committed
url payload generator should detect all-caps protocol
1 parent cecf206 commit 4e88511

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

QRCoder/PayloadGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public class Url : Payload
311311
private readonly string url;
312312

313313
/// <summary>
314-
/// Generates a link. If not given, http/https protocol will be added.
314+
/// Generates a link. If protocol not given, http protocol will be added.
315315
/// </summary>
316316
/// <param name="url">Link url target</param>
317317
public Url(string url)
@@ -321,7 +321,7 @@ public Url(string url)
321321

322322
public override string ToString()
323323
{
324-
return (!this.url.StartsWith("http") ? "http://" + this.url : this.url);
324+
return (!this.url.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? "http://" + this.url : this.url);
325325
}
326326
}
327327

QRCoderTests/PayloadGeneratorTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,18 @@ public void url_should_build_https()
744744
}
745745

746746

747+
[Fact]
748+
[Category("PayloadGenerator/Url")]
749+
public void url_should_build_https_all_caps()
750+
{
751+
var url = "HTTPS://CODE-BUDE.NET";
752+
753+
var generator = new PayloadGenerator.Url(url);
754+
755+
generator.ToString().ShouldBe("HTTPS://CODE-BUDE.NET");
756+
}
757+
758+
747759
[Fact]
748760
[Category("PayloadGenerator/Url")]
749761
public void url_should_add_http()

0 commit comments

Comments
 (0)