mirror of
https://github.com/soxoj/maigret.git
synced 2026-09-22 17:54:55 +02:00
Escape the dollar sign when building profile URL regexps (#3051)
This commit is contained in:
+1
-1
@@ -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:
|
||||
|
||||
@@ -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'}))
|
||||
|
||||
Reference in New Issue
Block a user