Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect redd.it/xxxxxx shortlinks #1007

Merged
merged 2 commits into from
Sep 28, 2024
Merged

Conversation

DokterKaj
Copy link
Contributor

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
Copy link
Contributor Author

Close #1004 as well

@ManeraKai
Copy link
Member

ManeraKai commented Sep 28, 2024

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

@DokterKaj
Copy link
Contributor Author

DokterKaj commented Sep 28, 2024

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

@ManeraKai ManeraKai merged commit 8b345ca into libredirect:master Sep 28, 2024
3 checks passed
@DokterKaj DokterKaj deleted the patch-1 branch September 28, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Redirect "redd.it" shortlinks
2 participants