From a5944c1d0682800274919e682210f28bc711d262 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Tue, 1 Feb 2022 19:15:18 +0000 Subject: [PATCH] :zap: Adds type checking for section search --- src/components/Workspace/SideBar.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Workspace/SideBar.vue b/src/components/Workspace/SideBar.vue index 40ac0d02..2442403c 100644 --- a/src/components/Workspace/SideBar.vue +++ b/src/components/Workspace/SideBar.vue @@ -64,10 +64,10 @@ export default { /* If an initial URL is specified, then open relevant section */ openDefaultSection() { if (!this.initUrl) return; - const process = (url) => url.replace(/[^\w\s]/gi, '').toLowerCase(); + const process = (url) => (url ? url.replace(/[^\w\s]/gi, '').toLowerCase() : undefined); const compare = (item) => (process(item.url) === process(this.initUrl)); - this.sections.forEach((section, sectionIndex) => { - if (section.items.findIndex(compare) !== -1) this.openSection(sectionIndex); + this.sections.forEach((section, secIndex) => { + if (section.items && section.items.findIndex(compare) !== -1) this.openSection(secIndex); }); }, },