Refactor redirect URL code block into a function
This commit is contained in:
parent
a6ca591fee
commit
8eff9df6de
|
@ -2,7 +2,11 @@ const currentUrl = window.location.href;
|
||||||
const oldDomain = 'leilukin.neocities.org';
|
const oldDomain = 'leilukin.neocities.org';
|
||||||
const newDomain = 'leilukin.com';
|
const newDomain = 'leilukin.com';
|
||||||
|
|
||||||
if (currentUrl.includes(oldDomain)) {
|
const redirectUrl = (oldStr, newStr) => {
|
||||||
const newUrl = currentUrl.replace(oldDomain, newDomain);
|
if (currentUrl.includes(oldStr)) {
|
||||||
|
const newUrl = currentUrl.replace(oldStr, newStr);
|
||||||
location.replace(newUrl);
|
location.replace(newUrl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectUrl(oldDomain, newDomain);
|
Loading…
Reference in New Issue