From 5ebf011998fa55901ed78343277845935b58abc3 Mon Sep 17 00:00:00 2001 From: Mike Tschudi Date: Mon, 20 Nov 2023 11:37:31 -0800 Subject: [PATCH] Templatize encoded portal urls in storymaps #1299 --- .../src/helpers/add-content-to-solution.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/creator/src/helpers/add-content-to-solution.ts b/packages/creator/src/helpers/add-content-to-solution.ts index d6fc03736..d595a6d06 100644 --- a/packages/creator/src/helpers/add-content-to-solution.ts +++ b/packages/creator/src/helpers/add-content-to-solution.ts @@ -547,7 +547,7 @@ export function _templatizeOrgUrl( return new Promise((resolve, reject) => { // Get the org's URL getPortal(null, destAuthentication).then(org => { - const orgUrl = "https://" + org.urlKey + "." + org.customBaseUrl; + let orgUrl = "https://" + org.urlKey + "." + org.customBaseUrl; const templatizedOrgUrl = "{{portalBaseUrl}}"; // Cycle through each of the items in the template and scan the `item` and `data` sections of each for replacements @@ -563,6 +563,19 @@ export function _templatizeOrgUrl( templatizedOrgUrl ); }); + + // Handle encoded URLs + orgUrl = orgUrl.replace("https://", "https%3A%2F%2F"); + + // Cycle through each of the items in the template and scan the `data` sections of each for replacements + templates.forEach((template: IItemTemplate) => { + globalStringReplace( + template.data, + new RegExp(orgUrl, "gi"), + templatizedOrgUrl + ); + }); + resolve(templates); }, reject); });