Skip to content

Commit bfbb825

Browse files
committed
doc: add changelog, comments
1 parent c46441f commit bfbb825

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
## [unreleased]
1010

1111
## [0.29.0] - 2025-02-17
12+
- **[Breaking] Makes URL path normalization case sensitive**
13+
- Updates `normalise_url_path_or_throw_error` to be case sensitive
14+
- URL paths will not be converted to lower-case, and will be kept as-is.
1215
- Fixes an issue where `removeDevice` API allowed removing TOTP devices without the user completing MFA.
1316
- Brings SDK in-line with Node SDK v21.1.0
1417

supertokens_python/normalised_url_path.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ def is_a_recipe_path(self) -> bool:
4545

4646

4747
def normalise_url_path_or_throw_error(input_str: str) -> str:
48+
"""
49+
Normalize URLs and obtain their path.
50+
"""
4851
input_str = input_str.strip()
4952
input_str_lower = input_str.lower()
5053

5154
try:
5255
if not input_str_lower.startswith(("http://", "https://")):
56+
# Raise and fall-through to handling below
5357
raise Exception("converting to proper URL")
5458

5559
url_obj = urlparse(input_str)
@@ -62,15 +66,18 @@ def normalise_url_path_or_throw_error(input_str: str) -> str:
6266
except Exception:
6367
pass
6468

69+
# URL specifies a domain but no scheme, try parsing with scheme added
6570
if (
6671
domain_given(input_str_lower) or input_str_lower.startswith("localhost")
6772
) and not input_str_lower.startswith(("http://", "https://")):
6873
input_str = "http://" + input_str
6974
return normalise_url_path_or_throw_error(input_str)
7075

76+
# Only a path given, add a leading slash
7177
if not input_str.startswith("/"):
7278
input_str = "/" + input_str
7379

80+
# Parse the path with a dummy scheme and domain
7481
try:
7582
urlparse(f"http://example.com{input_str}")
7683
return normalise_url_path_or_throw_error(f"http://example.com{input_str}")

0 commit comments

Comments
 (0)