From 2e20b1e2977228c04c38c4e3eb127daf5ccce7c0 Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Sun, 1 Aug 2021 20:17:23 +0200 Subject: [PATCH] fix: :bug: less harsh falsey checking on rawValues content Check only for !== undefined wasn't too specific,. Now it checks that the content is truthy --- src/sharedFunctions.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index e0b003d7..93156a01 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -173,28 +173,25 @@ export function getFieldValues( settings: BreadcrumbsSettings ) { // Narrow down the possible types - const rawValues: (string | dvLink)[] = + const rawValues: (string | dvLink | undefined)[] = [frontmatterCache?.[field]].flat(5) ?? null; - // If there are any values for that field, and they're not undefined (Forget why that can happen...) - if (rawValues.length && rawValues[0] !== undefined) { + superDebug(settings, `${field} of: ${frontmatterCache.file.path}`); + superDebug(settings, { rawValues }); + + // If there are any values for that field, and they're not undefined + if (rawValues.length && rawValues[0]) { if (typeof rawValues[0] === "string") { - superDebug(settings, `${field} of: ${frontmatterCache.file.path}`); - superDebug(settings, { rawValues }); return splitAndDrop(rawValues[0]).map((str: string) => str.split("/").last() ); } else { // Assuming it's a dvLink - superDebug(settings, `${field} of: ${frontmatterCache.file.path}`); - superDebug(settings, { rawValues }); return (rawValues as dvLink[]).map((link: dvLink) => link.path.split("/").last() ); } } else { - superDebug(settings, `${field} of: ${frontmatterCache.file.path}`); - superDebug(settings, { rawValues }); return []; } }