mirror of https://github.com/go-gitea/gitea.git
Updated URL search params manipulation
This commit is contained in:
parent
bb6778500f
commit
2acc230cf0
|
|
@ -31,22 +31,13 @@ export function initCommitFileHistoryFollowRename() {
|
|||
if (!checkbox) {
|
||||
return;
|
||||
}
|
||||
checkbox.checked = location.toString().includes('history_follow_rename=true');
|
||||
const url = new URL(window.location.toString());
|
||||
checkbox.checked = url.searchParams.has('history_follow_rename', 'true');
|
||||
|
||||
checkbox.addEventListener('change', () => {
|
||||
let url = location.toString();
|
||||
const url = new URL(location.toString());
|
||||
|
||||
url = url.replaceAll(/history_follow_rename=(true|false)&*/g, '');
|
||||
if (url.endsWith('?')) {
|
||||
url = url.slice(0, -1);
|
||||
}
|
||||
if (url.includes('?')) {
|
||||
url += '&';
|
||||
} else {
|
||||
url += '?';
|
||||
}
|
||||
|
||||
url += `history_follow_rename=${checkbox.checked}`;
|
||||
window.location.href = url;
|
||||
url.searchParams.set('history_follow_rename', `${checkbox.checked}`);
|
||||
window.location.replace(url);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue