Skip to content

Commit

Permalink
fix(tags): prune out empty tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Dec 17, 2024
1 parent bbbf50b commit de0ec83
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 de0ec83

Please sign in to comment.