Skip to content

Commit

Permalink
Merge pull request #447 from mharen/all-caps-url-payload-generator
Browse files Browse the repository at this point in the history
url payload generator should detect all-caps protocol
  • Loading branch information
codebude authored Apr 17, 2024
2 parents 5f9f437 + 9f712fe commit a24c984
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions QRCoder/PayloadGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public class Url : Payload
private readonly string url;

/// <summary>
/// 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.
/// </summary>
/// <param name="url">Link url target</param>
public Url(string url)
Expand All @@ -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);
}
}

Expand Down
12 changes: 12 additions & 0 deletions QRCoderTests/PayloadGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a24c984

Please sign in to comment.