From 57f2ac65f2d809b2284affe716dd5e611ec10524 Mon Sep 17 00:00:00 2001 From: Brian Miller Date: Wed, 6 Nov 2024 08:50:26 -0600 Subject: [PATCH 1/2] Add redirect handling of queryParams Only came up cause I re tested on watt and they have a bunch of queryParams appended to their links withing the content section feed. http://www-feedandgrain.dev.parameter1.com:9925/brand-insights/zoetis/vaccination-success-depends-on-crew-training/67094ddcc2bbee3e1b1af57d?pubid=644d5a06b225a200013c2da3&utm_source=NativeX&utm_medium=banner&utm_campaign=65943beafce1d00001661a52&utm_term=6452f9113738d30001f886aa&utm_content=65943beafce1d00001661a54 the following with and in valid primary section alias should redirect to the above now. http://www-feedandgrain.dev.parameter1.com:9925/brand-insights/zoetis/vaccination-training/67094ddcc2bbee3e1b1af57d?pubid=644d5a06b225a200013c2da3&utm_source=NativeX&utm_medium=banner&utm_campaign=65943beafce1d00001661a52&utm_term=6452f9113738d30001f886aa&utm_content=65943beafce1d00001661a54 --- .../middleware/get-advertising-post-as-native-story.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js b/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js index 9dbf321e4..d5839f77f 100644 --- a/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js +++ b/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js @@ -30,7 +30,12 @@ module.exports = (app, { // redirect path to story url if url does not match. const storyURL = new URL(story.url); if (storyURL.pathname !== path) { - res.redirect(301, storyURL.pathname); + // account for redirecting with all of the queryParams + const newUrl = req.query && Object.keys(req.query).length !== 0 + ? `${storyURL.pathname}?${new URLSearchParams(req.query).toString()}` + : storyURL.pathname + ; + res.redirect(301, newUrl); return; } From 1c934ff2491d4c4ac9fb54ecfba4bb7363cf8e81 Mon Sep 17 00:00:00 2001 From: Brian Miller Date: Wed, 6 Nov 2024 09:04:23 -0600 Subject: [PATCH 2/2] fix lint error --- .../middleware/get-advertising-post-as-native-story.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js b/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js index d5839f77f..dc71dac03 100644 --- a/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js +++ b/packages/mindful/marko-web/middleware/get-advertising-post-as-native-story.js @@ -33,8 +33,7 @@ module.exports = (app, { // account for redirecting with all of the queryParams const newUrl = req.query && Object.keys(req.query).length !== 0 ? `${storyURL.pathname}?${new URLSearchParams(req.query).toString()}` - : storyURL.pathname - ; + : storyURL.pathname; res.redirect(301, newUrl); return; }