api/reddit: add support for short links

This commit is contained in:
Felix Vuong 🍂
2025-03-29 13:29:22 +07:00
committed by jj
parent 1477dcd4e7
commit b1bde25dee
5 changed files with 49 additions and 3 deletions

View File

@@ -106,6 +106,14 @@ function aliasURL(url) {
url.pathname = `/share/${idPart.slice(-32)}`;
}
break;
case "redd":
/* reddit short video links can be treated by changing https://v.redd.it/<id>
to https://reddit.com/video/<id>.*/
if (url.hostname === "v.redd.it" && parts.length === 2) {
url = new URL(`https://www.reddit.com/video/${parts[1]}`);
}
break;
}
return url;