Fix regex since Fandom subdomains can contain hyphens (#37)
For example, it wouldn't redirect https://kimetsu-no-yaiba.fandom.com/wiki/Kimetsu_no_Yaiba_Wiki, now it would Reviewed-on: https://codeberg.org/LibRedirect/libredirect/pulls/37 Co-authored-by: Austin Huang <im@austinhuang.me> Co-committed-by: Austin Huang <im@austinhuang.me>
This commit is contained in:
parent
ac4c89de78
commit
91d420b460
|
@ -393,7 +393,7 @@ function redirect(url, type, initiator, forceRedirection) {
|
|||
}
|
||||
return randomInstance
|
||||
case "breezeWiki":
|
||||
let wiki = url.hostname.match(/^[a-zA-Z0-9]+(?=\.fandom\.com)/)
|
||||
let wiki = url.hostname.match(/^[a-zA-Z0-9-]+(?=\.fandom\.com)/)
|
||||
if (wiki == "www" || !wiki) wiki = ""
|
||||
else wiki = "/" + wiki
|
||||
if (url.href.search(/Special:Search\?query/) > -1) return `${randomInstance}${wiki}${url.pathname}${url.search}`.replace(/Special:Search\?query/, "search?q").replace(/\/wiki/, "")
|
||||
|
|
|
@ -456,7 +456,7 @@
|
|||
}
|
||||
},
|
||||
"targets": [
|
||||
"^https?:\\/{2}(?:[a-zA-Z0-9]+\\.)?fandom\\.com(?=(?:\\/wiki)|(?:\\/?$))"
|
||||
"^https?:\\/{2}(?:[a-zA-Z0-9-]+\\.)?fandom\\.com(?=(?:\\/wiki)|(?:\\/?$))"
|
||||
],
|
||||
"name": "Fandom",
|
||||
"options": {
|
||||
|
|
Loading…
Reference in New Issue