Skip to content

Commit

Permalink
fix: flattenToAppUrl to prefix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jan 11, 2024
1 parent 89359a9 commit 2d2c981
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/customizations/volto/helpers/Url/Url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, '')
Expand Down

0 comments on commit 2d2c981

Please sign in to comment.