Escape the dollar sign when building profile URL regexps (#3051)

This commit is contained in:
Sushanth012
2026-08-31 10:31:38 +02:00
committed by GitHub
parent 3df91b4d7a
commit a2c964bfc2
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ def enrich_link_str(link: str) -> str:
class URLMatcher:
_HTTP_URL_RE_STR = r"^https?://(www\.|m\.)?(.+)$"
HTTP_URL_RE = re.compile(_HTTP_URL_RE_STR)
UNSAFE_SYMBOLS = ".?"
UNSAFE_SYMBOLS = ".?$"
@classmethod
def extract_main_part(self, url: str) -> str:
+15
View File
@@ -184,6 +184,21 @@ def test_extract_id_from_url_skips_none_groups():
)
def test_extract_id_from_url_handles_literal_dollar_prefix():
site = MaigretSite(
"Cash App",
{
"urlMain": "https://cash.app",
"url": "https://cash.app/${username}",
},
)
assert site.extract_id_from_url("https://cash.app/$alice") == (
"alice",
"username",
)
def test_ranked_sites_dict():
db = MaigretDatabase()
db.update_site(MaigretSite('3', {'alexaRank': 1000, 'engine': 'ucoz'}))