aboutsummaryrefslogtreecommitdiffstats
path: root/src/assets
diff options
context:
space:
mode:
Diffstat (limited to 'src/assets')
-rw-r--r--src/assets/javascripts/services.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 80a4851c..e85b5bf1 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -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
}
@@ -267,8 +269,11 @@ function rewrite(url, originUrl, frontend, randomInstance) {
// https://stackexchange.com or https://superuser.com
return `${randomInstance}${url.pathname}${url.search}`
}
- const regex = url.href.match(/https?:\/{2}(?:([a-zA-Z0-9-]+)\.)?stackexchange\.com\//)
+ const regex = url.href.match(/https?:\/{2}(?:([a-zA-Z0-9-]+)\.(meta\.)?)?stackexchange\.com\//)
if (regex && regex.length > 1) {
+ if (regex[2]) {
+ return `${randomInstance}/exchange/${url.hostname}${url.pathname}${url.search}`
+ }
const subdomain = regex[1]
return `${randomInstance}/exchange/${subdomain}${url.pathname}${url.search}`
}