Skip to content

Commit 10fe10b

Browse files
authored
Merge pull request #2874 from T90REAL/fix_case_sensitivity
2 parents 880d87f + bc06327 commit 10fe10b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,4 @@ Contributors (chronological)
180180
- Nicolas Simonds `@0xDEC0DE <https://github.com/0xDEC0DE>`_
181181
- Florian Laport `@Florian-Laport <https://github.com/Florian-Laport>`_
182182
- `@agentgodzilla <https://github.com/agentgodzilla>`_
183+
- Xiao `@T90REAL <https://github.com/T90REAL>`_

src/marshmallow/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __init__(
187187
self.relative = relative
188188
self.absolute = absolute
189189
self.error: str = error or self.default_message
190-
self.schemes = schemes or self.default_schemes
190+
self.schemes = {s.lower() for s in schemes} if schemes else self.default_schemes
191191
self.require_tld = require_tld
192192

193193
def _repr_args(self) -> str:

tests/test_validate.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ def test_url_custom_scheme():
205205
assert validator(url) == url
206206

207207

208+
def test_url_custom_scheme_case_insensitive():
209+
validator = validate.URL(schemes={"HTTP"})
210+
assert validator("http://example.com") == "http://example.com"
211+
212+
validator = validate.URL(schemes={"HtTp"})
213+
assert validator("hTtP://example.com") == "hTtP://example.com"
214+
215+
208216
@pytest.mark.parametrize(
209217
"valid_url",
210218
(

0 commit comments

Comments
 (0)