skillhub/web/base-path-config.test.ts
千乘妍 (Xiaoyaner) 7fb74e81b2 feat(deploy): configure same-origin optional analytics
Safely transport bounded JSON using existing image tools, generate isolated exact proxy routes with verified HTTPS, and wire Compose and Helm with closed defaults.

Refs #989

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
2026-10-29 23:16:31 +08:00

40 lines
1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { validateBasePath } from './base-path-config'
describe('validateBasePath', () => {
it.each(['/skillhub/', '/foo.bar/', '/a_b~c/'])('accepts %s', (value) => {
expect(validateBasePath(value)).toBe(value)
})
it('accepts root deployment', () => {
expect(validateBasePath('/')).toBe('/')
})
it.each([
'//cdn.example/',
'/foo//bar/',
'/foo/../bar/',
'/foo/./bar/',
'/foo bar/',
'skillhub/',
'/skillhub',
])('rejects unsafe or malformed value %s', (value) => {
expect(() => validateBasePath(value)).toThrow(/VITE_BASE_PATH/)
})
it.each([
'/api/',
'/oauth2/',
'/login/',
'/assets/',
'/registry/',
'/nginx-health/',
'/.well-known/',
'/runtime-config.js/',
'/api/nested/',
'/_skillhub-analytics/',
'/_skillhub-analytics/nested/',
])('rejects reserved first segment %s', (value) => {
expect(() => validateBasePath(value)).toThrow(/reserved by the SkillHub server/)
})
})