Repository navigation
Commit 045720b
committed
fix: is_same_host returns False for bare hostnames (no scheme)
urlparse treats a string with no scheme as an opaque path, so
urlparse("host.example.com").netloc is "" while
urlparse("https://host.example.com").netloc is "host.example.com".
is_same_host therefore returned False whenever one of its arguments
lacked a scheme — for example a JWT iss claim stored as a bare
hostname vs. self.hostname which is always normalized with https://.
Fix: extract a nested helper _extract_host that re-parses with a
dummy "https://" prefix when the initial parse yields an empty
netloc, recovering the actual hostname in the bare-hostname case.
Also normalises extracted hosts to lowercase for a consistent
comparison.
Add four new parametrize cases to test_is_same_host covering the
previously failing mixed-scheme and bare-vs-bare comparisons.
Signed-off-by: Shubham-Padkonde <shubhampadkonde12@gmail.com>1 parent 70427d7 commit 045720b
2 files changed
Lines changed: 19 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
325 | 331 | | |
326 | 332 | | |
327 | 333 | | |
| |||
0 commit comments