mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
19 lines
716 B
TypeScript
19 lines
716 B
TypeScript
/** Shared loopback-hostname semantics for the Host fence and browser UI. */
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import { isLoopbackHostname } from '../src/loopback-hostname.ts'
|
|
|
|
describe('isLoopbackHostname', () => {
|
|
it('accepts localhost, IPv6 loopback, and the whole IPv4 127/8 block', () => {
|
|
for (const hostname of ['localhost', '[::1]', '127.0.0.1', '127.8.9.10', '127.255.255.255']) {
|
|
expect(isLoopbackHostname(hostname)).toBe(true)
|
|
}
|
|
})
|
|
|
|
it('refuses malformed and non-loopback hostnames', () => {
|
|
for (const hostname of ['remote.localhost', '::1', '128.0.0.1', '127.0.0', '127.0.0.256', '127.0.0.-1']) {
|
|
expect(isLoopbackHostname(hostname)).toBe(false)
|
|
}
|
|
})
|
|
})
|