Comment on I wrote hacky tampermonkey script to fix Lemmy instance links. Any advice?
ezchili@iusearchlinux.fyi 1 year agoNever use regex on URLs, make a list of hostnames and use the browser’s URL api to extract hostnames then match against the list
Andy@programming.dev 1 year ago
Can you provide an example URL that breaks this solution?
ezchili@iusearchlinux.fyi 1 year ago
Sure!
user:pw@lemdro.id:80 is a valid url to lemdro.id and should match but will not
maliciouswebsite.to/?q=http://lemdro.id will match but should not
Andy@programming.dev 1 year ago
Well that one:
No, it does not match.
AFAICT, this solution is working properly, but if you can find a URL that breaks it, please let me know.
ezchili@iusearchlinux.fyi 1 year ago
Lmao ok