From e07651b93164d727f3c79053f900935f7ed7fd6c Mon Sep 17 00:00:00 2001 From: RaidMax Date: Tue, 28 Jun 2022 10:03:05 -0500 Subject: [PATCH] fix toast message issue on pages with query params --- WebfrontCore/wwwroot/js/action.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/WebfrontCore/wwwroot/js/action.js b/WebfrontCore/wwwroot/js/action.js index 92c1f5564..9fcd630a0 100644 --- a/WebfrontCore/wwwroot/js/action.js +++ b/WebfrontCore/wwwroot/js/action.js @@ -57,6 +57,15 @@ function escapeHtml (string) { }); } +function buildToastUri(message, duration) { + let uri = '&'; + if (window.location.href.toString().indexOf('?') <= 0) { + uri = '?'; + } + uri += `toastMessage=${escape(message)}${duration ? `&duration=${duration}` : ''}`; + return uri; +} + $(document).ready(function () { let toastMessage = getUrlParameter('toastMessage'); @@ -130,7 +139,7 @@ $(document).ready(function () { } catch{} if (shouldRefresh) { - window.location = `${window.location.href.replace('#', '')}?toastMessage=${escape(message)}${duration ? `&duration=${duration}` : ''}`; + window.location = `${window.location.href.replace('#', '')}${buildToastUri(message, duration)}`; } else { modal.modal();