Merge pull request #1007 from DokterKaj/patch-1
Redirect redd.it/xxxxxx shortlinks
This commit is contained in:
commit
8b345ca2b9
|
@ -220,15 +220,17 @@ function rewrite(url, originUrl, frontend, randomInstance) {
|
||||||
return `${randomInstance}${url.pathname}${url.search}`
|
return `${randomInstance}${url.pathname}${url.search}`
|
||||||
case "redlib":
|
case "redlib":
|
||||||
case "libreddit": {
|
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}`
|
if (!subdomain) return `${randomInstance}${url.pathname}${url.search}`
|
||||||
switch (subdomain[0]) {
|
switch (subdomain[1]) {
|
||||||
case "preview":
|
case "preview":
|
||||||
return `${randomInstance}/preview/pre${url.pathname}${url.search}`
|
return `${randomInstance}/preview/pre${url.pathname}${url.search}`
|
||||||
case "external-preview":
|
case "external-preview":
|
||||||
return `${randomInstance}/preview/external-pre${url.pathname}${url.search}`
|
return `${randomInstance}/preview/external-pre${url.pathname}${url.search}`
|
||||||
case "i":
|
case "i":
|
||||||
return `${randomInstance}/img${url.pathname}`
|
return `${randomInstance}/img${url.pathname}`
|
||||||
|
default:
|
||||||
|
return `${randomInstance}/comments${url.pathname}`
|
||||||
}
|
}
|
||||||
return randomInstance
|
return randomInstance
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,8 +268,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
"^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.)?(reddit|reddittorjg6rue252oqsxryoxengawnmo46qy4kyii5wtqnwfj4ooad)\\.(com|onion)(?=\\/u(ser)?\\/|\\/r\\/|\\/search|\\/new|\\/?$)",
|
"^https?:\\/{2}(www\\.|old\\.|np\\.|new\\.|amp\\.)?(reddit|reddittorjg6rue252oqsxryoxengawnmo46qy4kyii5wtqnwfj4ooad)\\.(com|onion)(?=\\/u(ser)?\\/|\\/r\\/|\\/search|\\/new|\\/comments|\\/?$)",
|
||||||
"^https?:\\/{2}(i|(external-)?preview)\\.redd\\.it"
|
"^https?:\\/{2}((i|(external-)?preview)\\.)?redd\\.it"
|
||||||
],
|
],
|
||||||
"name": "Reddit",
|
"name": "Reddit",
|
||||||
"options": {
|
"options": {
|
||||||
|
|
Loading…
Reference in New Issue