We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
isMatchFilter()
1 parent 37cbabf commit ee8566bCopy full SHA for ee8566b
rest/getCodeBlocks.ts
@@ -108,9 +108,11 @@ function isMatchFilter(
108
codeBlock: TinyCodeBlock,
109
filter?: GetCodeBlocksFilter,
110
): boolean {
111
- if (filter?.filename && filter.filename !== codeBlock.filename) return false;
112
- if (filter?.lang && filter.lang !== codeBlock.lang) return false;
113
- return true;
+ const equals = (a: unknown, b: unknown) => !a || a === b;
+ return (
+ equals(filter?.filename, codeBlock.filename) &&
114
+ equals(filter?.lang, codeBlock.lang)
115
+ );
116
}
117
118
/** 行テキストがコードブロックの一部であればそのテキストを、そうでなければnullを返す
0 commit comments