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 newDomain = 'leilukin.com';
|
||||
|
||||
if (currentUrl.includes(oldDomain)) {
|
||||
const newUrl = currentUrl.replace(oldDomain, newDomain);
|
||||
location.replace(newUrl);
|
||||
}
|
||||
const redirectUrl = (oldStr, newStr) => {
|
||||
if (currentUrl.includes(oldStr)) {
|
||||
const newUrl = currentUrl.replace(oldStr, newStr);
|
||||
location.replace(newUrl);
|
||||
}
|
||||
}
|
||||
|
||||
redirectUrl(oldDomain, newDomain);
|
Loading…
Reference in New Issue