Lowercase scheme and host to better align with RFC 6454.
This commit is contained in:
parent
6657831463
commit
feceb3ddea
|
|
@ -38,9 +38,9 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
|
||||||
/// <returns>The current policy builder.</returns>
|
/// <returns>The current policy builder.</returns>
|
||||||
public CorsPolicyBuilder WithOrigins(params string[] origins)
|
public CorsPolicyBuilder WithOrigins(params string[] origins)
|
||||||
{
|
{
|
||||||
foreach (var req in origins)
|
foreach (var origin in origins)
|
||||||
{
|
{
|
||||||
_policy.Origins.Add(req);
|
_policy.Origins.Add(origin.ToLowerInvariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,17 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
|
||||||
Assert.Equal(new List<string>() { "http://example.com", "http://example2.com" }, corsPolicy.Origins);
|
Assert.Equal(new List<string>() { "http://example.com", "http://example2.com" }, corsPolicy.Origins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WithOrigins_NormalizesOrigins()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var builder = new CorsPolicyBuilder("http://www.EXAMPLE.com", "HTTPS://example2.com");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var corsPolicy = builder.Build();
|
||||||
|
Assert.Equal(new List<string>() { "http://www.example.com", "https://example2.com" }, corsPolicy.Origins);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AllowAnyOrigin_AllowsAny()
|
public void AllowAnyOrigin_AllowsAny()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue