Skip to content

Commit

Permalink
chore(website): caip19 to compare with case insensitive reference (#19)
Browse files Browse the repository at this point in the history
#### What this PR does / why we need it:

As per title.
  • Loading branch information
fuxingloh authored Nov 9, 2023
1 parent 2e9328c commit 57ee8b8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/crypto-frontmatter/src/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 57ee8b8

Please sign in to comment.