feat: enhance local provider URL validation to include private IPv4 and IPv6 addresses
This commit is contained in:
24
src/services/api/providerConfig.local.test.ts
Normal file
24
src/services/api/providerConfig.local.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { expect, test } from 'bun:test'
|
||||
|
||||
import { isLocalProviderUrl } from './providerConfig.js'
|
||||
|
||||
test('treats localhost endpoints as local', () => {
|
||||
expect(isLocalProviderUrl('http://localhost:11434/v1')).toBe(true)
|
||||
expect(isLocalProviderUrl('http://127.0.0.1:11434/v1')).toBe(true)
|
||||
expect(isLocalProviderUrl('http://0.0.0.0:11434/v1')).toBe(true)
|
||||
})
|
||||
|
||||
test('treats private IPv4 endpoints as local', () => {
|
||||
expect(isLocalProviderUrl('http://10.0.0.1:11434/v1')).toBe(true)
|
||||
expect(isLocalProviderUrl('http://172.16.0.1:11434/v1')).toBe(true)
|
||||
expect(isLocalProviderUrl('http://192.168.0.1:11434/v1')).toBe(true)
|
||||
})
|
||||
|
||||
test('treats .local hostnames as local', () => {
|
||||
expect(isLocalProviderUrl('http://ollama.local:11434/v1')).toBe(true)
|
||||
})
|
||||
|
||||
test('treats public hosts as remote', () => {
|
||||
expect(isLocalProviderUrl('http://203.0.113.1:11434/v1')).toBe(false)
|
||||
expect(isLocalProviderUrl('https://example.com/v1')).toBe(false)
|
||||
})
|
||||
Reference in New Issue
Block a user