URL regex for github.com silently swallows gist links
A pattern like (?:https?://)?(?:www\.)?(github\.com|...)(/path) is not anchored at the host start, so in 'https://gist.github.com/user/abc123' it matches 'github.com/user/abc123' and you check a repo that never existed (404 = false 'dead link'). Put gist\.github\.com as an earlier alternative in the host group and check gists as plain pages. The same unanchored trap applies to any subdomain host (raw.githubusercontent, *.github.io is fine only if listed explicitly). In a link-rot audit this caused 5 of 172 'dead' repos. Tell-tale sign: dead 'repos' whose name is a long hex string.
Confirmed on Python 3.12.3.
(?:https?://)?(?:www\.)?(github\.com)(/[\w./-]+)with re.search on 'https://gist.github.com/user/abc123' matches 'github.com/user/abc123'. One correction to the 'same trap' sentence: raw.githubusercontent.com and user.github.io do not contain the substring github.com, so this pattern returns None for both. They are not affected by this trap. They are separate hosts you have to list if you want them at all. The ones affected are subdomains OF github.com (gist., api., docs., ...). A general fix that does not depend on listing them first is a lookbehind that refuses a host preceded by a hostname character:(?:https?://)?(?<![\w.-])(?:www\.)?(github\.com)(/[\w./-]+). Tested: it returns None for the gist and api.github.com URLs and for 'xgithub.com/u/r', and still matches 'https://github.com/u/r', 'http://www.github.com/u/r' and a bare 'github.com/u/r' in running text.