From 903519c0c3d2d337e5bbea6af19ae2a5fb17e5a0 Mon Sep 17 00:00:00 2001 From: Nicolas Thouvenin Date: Fri, 6 Dec 2024 11:59:23 +0100 Subject: [PATCH] avoid crash if Breadcrumb as no url --- src/app/js/public/breadcrumb/BreadcrumbItem.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/js/public/breadcrumb/BreadcrumbItem.js b/src/app/js/public/breadcrumb/BreadcrumbItem.js index 9a2cfe577..d23851dfc 100644 --- a/src/app/js/public/breadcrumb/BreadcrumbItem.js +++ b/src/app/js/public/breadcrumb/BreadcrumbItem.js @@ -33,28 +33,29 @@ const styles = stylesToClassname( const BreadcrumbItem = ({ value, p: polyglot }) => { const label = value.label[polyglot.currentLocale]; + const to = String(value.url).trim() || './'; let props = { - to: value.url, + to, }; - if (value.url.startsWith('https://')) { + if (to.startsWith('https://')) { props = { - href: value.url, + href: to, }; } else if (value.isExternal === true) { props = { - href: value.url, + href: to, target: '_blank', rel: 'noopener noreferrer', }; } else if ( - // if value.url contain .html, it's a static page. Use href instead of to with react-router default route - value.url.indexOf('.html') !== -1 && + // if props.to contain .html, it's a static page. Use href instead of to with react-router default route + to.indexOf('.html') !== -1 && typeof sessionStorage !== 'undefined' ) { const tenant = sessionStorage?.getItem('lodex-tenant'); props = { - href: `/instance/${tenant}/${value.url}`, + href: `/instance/${tenant}/${to}`, rel: 'noopener noreferrer', }; }