mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 14:06:36 +08:00
bfd9de69af
Axios 默认序列化为 hosts[]=,Gin QueryArray("hosts") 读不到导致筛选失效;
后端兼容 hosts/hosts[],前端改为重复键序列化。
23 lines
727 B
TypeScript
23 lines
727 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { serializeSearchParams } from '@/lib/services/core/search-params';
|
|
|
|
describe('serializeSearchParams', () => {
|
|
it('serializes hosts arrays as repeated keys for Gin QueryArray', () => {
|
|
const query = serializeSearchParams({
|
|
hours: 168,
|
|
hosts: ['gist.arctel.de'],
|
|
});
|
|
expect(query).toBe('hours=168&hosts=gist.arctel.de');
|
|
});
|
|
|
|
it('serializes multiple hosts without bracket notation', () => {
|
|
const query = serializeSearchParams({
|
|
hosts: ['a.example', 'b.example'],
|
|
});
|
|
expect(query).toBe('hosts=a.example&hosts=b.example');
|
|
expect(query).not.toContain('hosts[]');
|
|
expect(query).not.toContain('hosts%5B%5D');
|
|
});
|
|
});
|