fix(patreon): handle the /cw/ creator-URL prefix in vanity extraction
CI / lint (push) Successful in 2s
CI / frontend-build (push) Successful in 25s
CI / backend-lint-and-test (push) Successful in 26s
CI / integration (push) Successful in 3m2s

A source URL like https://www.patreon.com/cw/Atole resolved vanity='cw' — the
vanity regex only skipped a /c/ prefix, so Patreon's current /cw/ ("creator
workspace") form fell through to the bare-vanity branch and captured the prefix
instead of the slug. Every /cw/ source then failed campaign-id resolution
(API + page-scrape both looked up "cw"). Operator-confirmed 2026-06-07 via the
new error text: source_url='.../cw/Atole'; vanity='cw'.

Add cw/ to the optional prefix group (ordered before c/ so the longer prefix
wins), and have the creator-page fallback try the /cw/ form too. Test covers
bare / c/ / cw/ extraction and that id: URLs stay non-vanity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 20:34:15 -04:00
parent 19eb4e9388
commit c65da42593
2 changed files with 29 additions and 5 deletions
+14
View File
@@ -169,3 +169,17 @@ async def test_for_source_unresolvable_returns_none():
cid, resolved = await resolve_campaign_id_for_source("not-a-patreon-url", None, {})
assert cid is None
assert resolved is None
def test_extract_vanity_handles_all_path_prefixes():
"""Patreon serves the vanity bare and under c/ and cw/ prefixes; all must
yield the creator slug, not the prefix (operator-flagged 2026-06-07: a
/cw/Atole source resolved vanity='cw')."""
from backend.app.services.patreon_resolver import extract_vanity
assert extract_vanity("https://www.patreon.com/Atole") == "Atole"
assert extract_vanity("https://www.patreon.com/c/Atole") == "Atole"
assert extract_vanity("https://www.patreon.com/cw/Atole") == "Atole"
assert extract_vanity("https://patreon.com/cw/Atole") == "Atole"
# id: URLs are NOT vanities (handled by the id path).
assert extract_vanity("https://www.patreon.com/id:123") is None