From 57ee8b894a9f856ba6e12ee180c7934cbe68002a Mon Sep 17 00:00:00 2001 From: Fuxing Loh <4266087+fuxingloh@users.noreply.github.com> Date: Thu, 9 Nov 2023 18:14:44 +0800 Subject: [PATCH] chore(website): caip19 to compare with case insensitive reference (#19) #### What this PR does / why we need it: As per title. --- packages/crypto-frontmatter/src/frontmatter.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/crypto-frontmatter/src/frontmatter.ts b/packages/crypto-frontmatter/src/frontmatter.ts index 1ac2096c9..d46ba2e1e 100644 --- a/packages/crypto-frontmatter/src/frontmatter.ts +++ b/packages/crypto-frontmatter/src/frontmatter.ts @@ -111,9 +111,12 @@ export function getFrontmatterCollection(caip2: string, type: string): Frontmatt * @return {FrontmatterIndex | undefined} */ export function getFrontmatterIndex(caip19: string): FrontmatterIndex | undefined { - const [caip2, type] = decodeCaip19(caip19); + const [caip2, type, reference] = decodeCaip19(caip19); const collection = getFrontmatterCollection(caip2, type); - const index = collection.find((value: FrontmatterIndex) => value.path === caip19); + const index = collection.find((value: FrontmatterIndex) => { + const [, , aReference] = decodeCaip19(value.path); + return aReference.toLowerCase() === reference.toLowerCase(); + }); if (index === undefined) { return undefined; } @@ -137,9 +140,12 @@ export function getFrontmatterIndex(caip19: string): FrontmatterIndex | undefine * @return {FrontmatterContent | undefined} */ export function getFrontmatterContent(caip19: string): FrontmatterContent | undefined { - const [caip2, type] = decodeCaip19(caip19); + const [caip2, type, reference] = decodeCaip19(caip19); const collection = getFrontmatterCollection(caip2, type); - const index = collection.find((value: FrontmatterIndex) => value.path === caip19); + const index = collection.find((value: FrontmatterIndex) => { + const [, , aReference] = decodeCaip19(value.path); + return aReference.toLowerCase() === reference.toLowerCase(); + }); if (index === undefined) { return undefined; }