Skip to content

Commit 61560b4

Browse files
committed
refactor: reuse isGenericTagQuery in filter schema
1 parent 57e1aa5 commit 61560b4

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Reuse isGenericTagQuery helper in filter schema to prevent regex divergence

src/schemas/filter-schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { z } from 'zod'
22

33
import { createdAtSchema, kindSchema, prefixSchema } from './base-schema'
4+
import { isGenericTagQuery } from '../utils/filter'
45

56
const knownFilterKeys = new Set(['ids', 'authors', 'kinds', 'since', 'until', 'limit'])
67

@@ -16,7 +17,7 @@ export const filterSchema = z
1617
.catchall(z.array(z.string().min(1).max(1024)))
1718
.superRefine((data, ctx) => {
1819
for (const key of Object.keys(data)) {
19-
if (!knownFilterKeys.has(key) && !/^#[a-z]$/.test(key)) {
20+
if (!knownFilterKeys.has(key) && !isGenericTagQuery(key)) {
2021
ctx.addIssue({
2122
code: z.ZodIssueCode.custom,
2223
message: `Unknown key: ${key}`,

0 commit comments

Comments
 (0)