Skip to content

Commit c804689

Browse files
feat: preserve pipe-delimited OR groups in tags DTO
Stop splitting tags on | so that OR-group tokens (e.g. cat|dog) are forwarded intact to the Universal Booru Wrapper, which applies the correct engine-specific OR syntax per booru engine. Pipelines the change through the full stack: App → | (user types 'cat OR dog') API → ['cat|dog'] (kept as OR-group token) Wrapper → '{ ~ cat ~ dog }' (Gelbooru) / '~cat ~dog' (Danbooru/e621)
1 parent c81cfa8 commit c804689

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/booru/dto/booru-queries.dto.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,21 @@ describe('booruQueryValuesPostsDTO', () => {
1212
expect(dto.tags).toEqual(['panty_&_stocking_with_garterbelt'])
1313
})
1414

15-
it('should split pipe-separated tags and decode each one', () => {
15+
it('should preserve pipe-separated OR-group tokens as a single element and decode each part', () => {
1616
const dto = plainToInstance(booruQueryValuesPostsDTO, {
1717
tags: 'panty_%26_stocking_with_garterbelt|rating%3Asafe'
1818
})
1919

20-
expect(dto.tags).toEqual(['panty_&_stocking_with_garterbelt', 'rating:safe'])
20+
expect(dto.tags).toEqual(['panty_&_stocking_with_garterbelt|rating:safe'])
2121
})
2222

23-
it('should normalize array tag inputs and keep tag array shape', () => {
23+
it('should normalize array tag inputs and keep OR-group tokens intact', () => {
2424
const dto = plainToInstance(booruQueryValuesPostsDTO, {
2525
tags: ['panty_%26_stocking_with_garterbelt|rating%3Asafe', 'score%3A%3E100']
2626
})
2727

2828
expect(dto.tags).toEqual([
29-
'panty_&_stocking_with_garterbelt',
30-
'rating:safe',
29+
'panty_&_stocking_with_garterbelt|rating:safe',
3130
'score:>100'
3231
])
3332
})

src/booru/dto/booru-queries.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class booruQueryValuesPostsDTO extends booruQueriesDTO {
188188

189189
return (Array.isArray(value) ? value : [value])
190190
.map((tag) => (typeof tag === 'string' ? tag : String(tag)))
191-
.flatMap((tag) => tag.trim().split('|'))
191+
.map((tag) => tag.trim())
192192
.map((tag) => {
193193
if (!/%[0-9A-Fa-f]{2}/.test(tag)) {
194194
return tag

0 commit comments

Comments
 (0)