Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/schemas/filter-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const filterSchema = z
.catchall(z.array(z.string().min(1).max(1024)))
.superRefine((data, ctx) => {
for (const key of Object.keys(data)) {
if (!knownFilterKeys.has(key) && !/^#[a-z]$/.test(key)) {
if (!knownFilterKeys.has(key) && !/^#[a-zA-Z]$/.test(key)) {
ctx.addIssue({
Comment thread
CKodidela marked this conversation as resolved.
code: z.ZodIssueCode.custom,
message: `Unknown key: ${key}`,
Expand Down
13 changes: 13 additions & 0 deletions test/unit/schemas/filter-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ describe('NIP-01', () => {
}
})

it('accepts uppercase tag filters (#A-Z)', () => {
const filterWithUppercase = {
...filter,
'#I': ['identifier1', 'identifier2'],
'#K': ['1111'],
'#E': ['aa', 'bb'],
'#A': ['10000:pubkey:dtag'],
}
const result = validateSchema(filterSchema)(filterWithUppercase)
expect(result.error).to.be.undefined
expect(result.value).to.deep.equal(filterWithUppercase)
})

it('returns same filter if filter is valid', () => {
const result = validateSchema(filterSchema)(filter)

Expand Down
Loading