mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-11-02 06:16:10 +00:00
fix(tests): match stub hosts on subdomains in the link verifier
`is_checkable` compared the hostname against STUB_HOSTS by equality, so the offline verifiers' `mainnet.example.com`, `rpc.example.com` and `x.example.com` stubs were treated as real URLs and `--live` failed trying to resolve them. Match the host or any subdomain of it instead. Anchored on a leading dot, so `notexample.com` and `example.com.evil.net` still count as real. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
de7fd2aa90
commit
2fc7d99c7e
@@ -34,9 +34,10 @@ EXTRA_FILES = ("README.md", "CLAUDE.md")
|
|||||||
|
|
||||||
URL = re.compile(r"https?://[^\s'\"()<>\]`,]+")
|
URL = re.compile(r"https?://[^\s'\"()<>\]`,]+")
|
||||||
|
|
||||||
# Hosts that are not meant to resolve. The offline verifiers point a stub client
|
# Hosts that are not meant to resolve, matched on the host and any subdomain of
|
||||||
# at unroutable addresses on purpose, and example.com is the domain RFC 2606
|
# it. The offline verifiers point a stub client at unroutable addresses on
|
||||||
# reserves for exactly the placeholder metadata URI a test coin is created with.
|
# purpose, and example.com is the domain RFC 2606 reserves for exactly the
|
||||||
|
# placeholder metadata URI a test coin is created with.
|
||||||
STUB_HOSTS = {
|
STUB_HOSTS = {
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
"dummy",
|
"dummy",
|
||||||
@@ -101,7 +102,7 @@ def is_checkable(url: str) -> bool:
|
|||||||
if "{" in url: # f-string template, e.g. an explorer link
|
if "{" in url: # f-string template, e.g. an explorer link
|
||||||
return False
|
return False
|
||||||
host = urlparse(url).hostname or ""
|
host = urlparse(url).hostname or ""
|
||||||
return host not in STUB_HOSTS
|
return not any(host == stub or host.endswith(f".{stub}") for stub in STUB_HOSTS)
|
||||||
|
|
||||||
|
|
||||||
def check_urls_well_formed(found: dict[str, list[str]]) -> None:
|
def check_urls_well_formed(found: dict[str, list[str]]) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user