Merge pull request #657 from wrexbe/656-fix-queryparams-contains

#656 QueryParams contains bug
This commit is contained in:
Todd Menier 2021-10-11 09:02:14 -05:00 committed by GitHub
commit 27d350ecdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -115,5 +115,13 @@ namespace Flurl.Test.UrlBuilder
var url = new Url(expected);
Assert.AreEqual(expected, url.ToString());
}
[Test] // #656
public void queryparams_uses_equals() {
var url = new Url("http://www.mysite.com?param=1");
// String gets boxed, so we need to use Equals, instead of ==
var contains = url.QueryParams.Contains("param", "1");
Assert.IsTrue(contains);
}
}
}

View File

@ -161,7 +161,7 @@ namespace Flurl
public bool Contains(string name) => _values.Contains(name);
/// <inheritdoc />>
public bool Contains(string name, object value) => _values.Any(qv => qv.Name == name && qv.Value.Value == value);
public bool Contains(string name, object value) => _values.Any(qv => qv.Name == name && qv.Value.Value.Equals(value));
}
/// <summary>