Skip to content

Commit ee8566b

Browse files
committed
isMatchFilter()の実装を少し変更
1 parent 37cbabf commit ee8566b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

rest/getCodeBlocks.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ function isMatchFilter(
108108
codeBlock: TinyCodeBlock,
109109
filter?: GetCodeBlocksFilter,
110110
): boolean {
111-
if (filter?.filename && filter.filename !== codeBlock.filename) return false;
112-
if (filter?.lang && filter.lang !== codeBlock.lang) return false;
113-
return true;
111+
const equals = (a: unknown, b: unknown) => !a || a === b;
112+
return (
113+
equals(filter?.filename, codeBlock.filename) &&
114+
equals(filter?.lang, codeBlock.lang)
115+
);
114116
}
115117

116118
/** 行テキストがコードブロックの一部であればそのテキストを、そうでなければnullを返す

0 commit comments

Comments
 (0)