Fix wish add modal re-appearing

This commit is contained in:
grandeljay 2022-06-14 22:11:19 +02:00
parent 3dc893fa77
commit 741fc7cdc7

View file

@ -511,6 +511,27 @@ $(function () {
validateWishURL(formAdd, buttonAdd, modalWishlistWishAdd);
return false;
},
onHide : function() {
/** Ugly URL */
var paramString = location.search.split('?')[1];
var queryString = new URLSearchParams(paramString);
if (queryString.has('wish_add')) {
queryString.delete('wish_add');
window.history.replaceState(null, document.title, '?' + queryString.toString());
}
/** Pretty URL */
var path = location.pathname;
var pathParts = path.split('/')
var pathAdd = pathParts[pathParts.length - 1];
var pathNew = path.substring(0, path.length - pathAdd.length - 1);
if (pathAdd.toLowerCase() === 'add') {
window.history.replaceState(null, document.title, pathNew);
}
}
});
});