libredirect / browser_extension

A browser extension that redirects popular sites to alternative privacy friendly frontends
https://libredirect.github.io
GNU General Public License v3.0
3.29k stars 122 forks source link

Redirect redd.it/xxxxxx shortlinks #1007

Closed DokterKaj closed 1 month ago

DokterKaj commented 1 month ago

Closes #991. subdomain[1] will be undefined when there is nothing before redd.it in the string but since there's nothing else to test I just made it default. To be rigorous it can be changed to case undefined though

DokterKaj commented 1 month ago

Close #1004 as well

ManeraKai commented 1 month ago

You can use (?:) to not capture the match.

DokterKaj commented 1 month ago

I'm purposely capturing (and using) the match since there's no good way to detect both an optional subdomain without the dot and the presence of redd.it using only positive lookaheads e.g. /^(?:(?:(?:external-)?preview|i)\.)?(?=\.redd\.it)/ keeps the dot and /^(?:(?:(?:external-)?preview|i)(?=\.))?(?=redd\.it)/ doesn't work