From 2d2c9811975c4a8baecd6b165c3b405b8659b2ee Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Thu, 11 Jan 2024 14:19:13 +0530 Subject: [PATCH] fix: flattenToAppUrl to prefix paths --- src/customizations/volto/helpers/Url/Url.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/customizations/volto/helpers/Url/Url.js b/src/customizations/volto/helpers/Url/Url.js index fe419e7..a0ab352 100644 --- a/src/customizations/volto/helpers/Url/Url.js +++ b/src/customizations/volto/helpers/Url/Url.js @@ -19,6 +19,7 @@ import { matchPath } from 'react-router'; * @param {string} url Url to be parsed. * @return {string} Base url of content object. */ + export const getBaseUrl = memoize((url) => { const { settings } = config; const prefix = settings.prefixPath; @@ -104,10 +105,14 @@ export function getView(url) { * @returns {string} Flattened URL to the app server */ export function flattenToAppURL(url) { + let adjustedUrl = url; const { settings } = config; + const prefix = settings.prefixPath; + if (prefix && adjustedUrl?.indexOf(prefix) === -1) + adjustedUrl = `${prefix}${adjustedUrl}`; return ( - url && - url + adjustedUrl && + adjustedUrl .replace(settings.internalApiPath, '') .replace(settings.apiPath, '') .replace(settings.publicURL, '')