From 3250462e726702006f63e36af484c4197cad35fc Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Sun, 15 Aug 2021 09:47:07 +0200 Subject: [PATCH] fix(getFieldValues): :bug: If using Obs cache, it sees number-only links as number[][], not string[][] --- src/sharedFunctions.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sharedFunctions.ts b/src/sharedFunctions.ts index 50a829c5..48213001 100644 --- a/src/sharedFunctions.ts +++ b/src/sharedFunctions.ts @@ -200,23 +200,25 @@ export function getFieldValues( ) { const values: string[] = []; try { - const rawValues: (string | dvLink | Pos | TFile | undefined)[] = [ + const rawValues: (string | number | dvLink | Pos | TFile | undefined)[] = [ frontmatterCache?.[field], - ].flat(5); + ].flat(4); superDebug(settings, `${field} of: ${frontmatterCache?.file?.path}`); superDebug(settings, { rawValues }); rawValues.forEach((rawItem) => { if (!rawItem) return; - if (typeof rawItem === "string") { - const splits = rawItem.match(splitLinksRegex); + if (typeof rawItem === "string" || typeof rawItem === "number") { + // Obs cache converts link of form: [[\d+]] to number[][] + const rawItemAsString = rawItem.toString(); + const splits = rawItemAsString.match(splitLinksRegex); if (splits !== null) { const strs = splits .map((link) => link.match(dropHeaderOrAlias)[1]) .map((str: string) => str.split("/").last()); } else { - values.push(rawItem.split("/").last()); + values.push(rawItemAsString.split("/").last()); } } else if (rawItem.path) { values.push((rawItem as dvLink).path.split("/").last());