mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 17:56:37 +08:00
fix(access-logs): 修复概览域名筛选参数 hosts[] 被 Gin 忽略
Axios 默认序列化为 hosts[]=,Gin QueryArray("hosts") 读不到导致筛选失效;
后端兼容 hosts/hosts[],前端改为重复键序列化。
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user