From 76e892538aefcaba41c8a8ebca0e52002454b7cc Mon Sep 17 00:00:00 2001 From: Guilherme de Freitas Date: Wed, 10 Apr 2024 13:23:36 +0100 Subject: [PATCH 1/2] Truncate redirect URL if visit/proposal is not in expected format --- .../src/js/modules/types/em/dc/redirect.vue | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/src/js/modules/types/em/dc/redirect.vue b/client/src/js/modules/types/em/dc/redirect.vue index da27a7d84..657433999 100644 --- a/client/src/js/modules/types/em/dc/redirect.vue +++ b/client/src/js/modules/types/em/dc/redirect.vue @@ -21,9 +21,25 @@ export default { }, 'computed': { redirectUrl: function () { + let redirectLocation = this.$store.state.appOptions.redirects.em; const visitStr = this.collection.queryParams.visit; - const [proposal, visit] = visitStr.split("-"); - return `${this.$store.state.appOptions.redirects.em}/proposals/${proposal}/sessions/${visit}` + + if (visitStr) { + const [proposal, visit] = visitStr.split("-"); + redirectLocation += `/proposals/${proposal}/sessions/${visit}`; + } else { + const pathParams = window.location.pathname.split("/"); + const lastParam = pathParams[pathParams.length - 1].split("-"); + + if(lastParam.length === 2) { + redirectLocation += `/proposals/${lastParam[0]}` + if(!isNaN(lastParam[1])) { + redirectLocation += `/sessions/${lastParam[1]}`; + } + } + } + + return redirectLocation; } }, } From c1eee45194bed2cccdafb8a010c2ef4a612f0634 Mon Sep 17 00:00:00 2001 From: Guilherme Francisco Date: Mon, 15 Apr 2024 14:24:13 +0100 Subject: [PATCH 2/2] Apply Mark's suggestion to accessing last member of array Co-authored-by: Mark W <24956497+ndg63276@users.noreply.github.com> --- client/src/js/modules/types/em/dc/redirect.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/js/modules/types/em/dc/redirect.vue b/client/src/js/modules/types/em/dc/redirect.vue index 657433999..92afee74b 100644 --- a/client/src/js/modules/types/em/dc/redirect.vue +++ b/client/src/js/modules/types/em/dc/redirect.vue @@ -29,7 +29,7 @@ export default { redirectLocation += `/proposals/${proposal}/sessions/${visit}`; } else { const pathParams = window.location.pathname.split("/"); - const lastParam = pathParams[pathParams.length - 1].split("-"); + const lastParam = pathParams.pop().split("-"); if(lastParam.length === 2) { redirectLocation += `/proposals/${lastParam[0]}`