(search) Translate cursed medium URLs to scribe.rip links via the search application

This commit is contained in:
Viktor Lofgren 2024-09-01 13:32:14 +02:00
parent e19dc9b13e
commit bfb7ed2c99

View File

@ -101,9 +101,22 @@ public class SearchQueryIndexService {
}
private EdgeUrl cleanUrl(EdgeUrl url) {
if (url.domain.topDomain.equals("fandom.com")) {
String subdomain = url.domain.subDomain;
return new EdgeUrl("https", new EdgeDomain("breezewiki.com"), null, "/" + subdomain + url.path, null);
String topdomain = url.domain.topDomain;
String subdomain = url.domain.subDomain;
String path = url.path;
if (topdomain.equals("fandom.com")) {
return new EdgeUrl("https", new EdgeDomain("breezewiki.com"), null, "/" + subdomain + path, null);
}
else if (topdomain.equals("medium.com")) {
if (!subdomain.isBlank()) {
return new EdgeUrl("https", new EdgeDomain("scribe.rip"), null, path, null);
}
else {
String article = path.substring(path.indexOf("/", 1));
return new EdgeUrl("https", new EdgeDomain("scribe.rip"), null, article, null);
}
}
return url;
}