Skip to content

Commit

Permalink
Merge pull request #1007 from DokterKaj/patch-1
Browse files Browse the repository at this point in the history
Redirect redd.it/xxxxxx shortlinks
  • Loading branch information
ManeraKai authored Sep 28, 2024
2 parents 0f880e1 + 33d2490 commit 8b345ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,17 @@ function rewrite(url, originUrl, frontend, randomInstance) {
return `${randomInstance}${url.pathname}${url.search}`
case "redlib":
case "libreddit": {
const subdomain = url.hostname.match(/^(?:(?:external-)?preview|i)(?=\.redd\.it)/)
const subdomain = url.hostname.match(/^(?:((?:external-)?preview|i)\.)?redd\.it/)
if (!subdomain) return `${randomInstance}${url.pathname}${url.search}`
switch (subdomain[0]) {
switch (subdomain[1]) {
case "preview":
return `${randomInstance}/preview/pre${url.pathname}${url.search}`
case "external-preview":
return `${randomInstance}/preview/external-pre${url.pathname}${url.search}`
case "i":
return `${randomInstance}/img${url.pathname}`
default:
return `${randomInstance}/comments${url.pathname}`
}
return randomInstance
}
Expand Down
6 changes: 3 additions & 3 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@
}
},
"targets": [
"^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.)?(reddit|reddittorjg6rue252oqsxryoxengawnmo46qy4kyii5wtqnwfj4ooad)\\.(com|onion)(?=\\/u(ser)?\\/|\\/r\\/|\\/search|\\/new|\\/?$)",
"^https?:\\/{2}(i|(external-)?preview)\\.redd\\.it"
"^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.)?(reddit|reddittorjg6rue252oqsxryoxengawnmo46qy4kyii5wtqnwfj4ooad)\\.(com|onion)(?=\\/u(ser)?\\/|\\/r\\/|\\/search|\\/new|\\/comments|\\/?$)",
"^https?:\\/{2}((i|(external-)?preview)\\.)?redd\\.it"
],
"name": "Reddit",
"options": {
Expand Down Expand Up @@ -1358,4 +1358,4 @@
"url": "https://coub.com"
}
}
}
}

0 comments on commit 8b345ca

Please sign in to comment.