Match a slug whole, and compare an allowed host name without case

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-29 19:42:10 +02:00
1 parent 0ffd0726e9
commit f61caddced
3 files changed
+26 -8

No files matched your search

+2 -2
View File
@@ -39,7 +39,7 @@ PAGE_SIZE = 50
#: (`127.0.0.1`, `[::1]`) or a single word never names a host the fetch could
#: be pointed at; `ats._get` still refuses every host but this one, redirects
#: included.
_HOST = re.compile(r"^[a-z0-9-]+(\.[a-z0-9-]+)*$")
_HOST = re.compile(r"[a-z0-9-]+(\.[a-z0-9-]+)*")
#: Teamtailor's own namespace in the feed, the `tt:` of `tt:locations`.
_TT = "{https://teamtailor.com/locations}"
@@ -60,7 +60,7 @@ def site(slug: str) -> str:
def slug_ok(slug: str) -> bool:
host = site(slug)
return bool(slug.strip()) and bool(_HOST.match(host)) \
return bool(slug) and slug == slug.strip() and bool(_HOST.fullmatch(host)) \
and not host.rsplit(".", 1)[-1].isdigit()