Skip to content

Commit

Permalink
Merge pull request #320 from ar-io/prune-tags-fix
Browse files Browse the repository at this point in the history
fix(tags): prune out empty tags
  • Loading branch information
dtfiedler authored Dec 17, 2024
2 parents bbbf50b + de0ec83 commit 99a0df4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/utils/arweave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ export function isBlockHeight(height: string | number): height is BlockHeight {
return height !== undefined && !isNaN(parseInt(height.toString()));
}

/**
* Prune tags that are undefined or empty.
* @param tags - The tags to prune.
* @returns The pruned tags.
*/
export const pruneTags = (
tags: { name: string; value: string | undefined }[],
): { name: string; value: string }[] => {
return tags.filter(
(tag: {
name: string;
value: string | undefined;
}): tag is { name: string; value: string } => tag.value !== undefined,
}): tag is { name: string; value: string } =>
tag.value !== undefined && tag.value !== '',
);
};

Expand Down

0 comments on commit 99a0df4

Please sign in to comment.