mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
* test: remove 262 low-value tests * test: remove 665 low-value tests --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
isEligibleLocalCertificateHost,
|
|
normalizeBrowserNavigationUrl,
|
|
normalizeExternalBrowserUrl,
|
|
redactKagiSessionToken
|
|
} from './browser-url'
|
|
|
|
describe('browser-url helpers', () => {
|
|
it('recognizes only canonical loopback certificate hosts', () => {
|
|
for (const hostname of [
|
|
'localhost',
|
|
'LOCALHOST.',
|
|
'app.localhost',
|
|
'deep.app.localhost.',
|
|
'127.0.0.1',
|
|
'127.255.255.255',
|
|
'::1',
|
|
'[::1]'
|
|
]) {
|
|
expect(isEligibleLocalCertificateHost(hostname), hostname).toBe(true)
|
|
}
|
|
for (const hostname of [
|
|
'0.0.0.0',
|
|
'::',
|
|
'[2001:db8::1]',
|
|
'192.168.1.1',
|
|
'localhost.example.com',
|
|
'notlocalhost',
|
|
'.localhost',
|
|
'-bad.localhost',
|
|
'bad-.localhost',
|
|
'127.0.0.999',
|
|
'127.00.0.1'
|
|
]) {
|
|
expect(isEligibleLocalCertificateHost(hostname), hostname).toBe(false)
|
|
}
|
|
})
|
|
|
|
it('rejects non-web schemes for in-app navigation', () => {
|
|
expect(normalizeBrowserNavigationUrl('javascript:alert(1)')).toBeNull()
|
|
expect(normalizeExternalBrowserUrl('about:blank')).toBeNull()
|
|
})
|
|
|
|
// Refuse file URLs externally: a remote page must not drive Finder/Explorer to arbitrary paths.
|
|
it('rejects file:// for external opens even though it is allowed in-app', () => {
|
|
expect(normalizeExternalBrowserUrl('file:///etc/passwd')).toBeNull()
|
|
expect(normalizeExternalBrowserUrl('\\\\server\\share\\Example.ipynb')).toBeNull()
|
|
})
|
|
|
|
it('redacts Kagi private session tokens from displayable URLs', () => {
|
|
expect(redactKagiSessionToken('https://kagi.com/search?token=secret&q=hello+world')).toBe(
|
|
'https://kagi.com/search?q=hello+world'
|
|
)
|
|
expect(redactKagiSessionToken('https://kagi.com/search?q=hello+world')).toBe(
|
|
'https://kagi.com/search?q=hello+world'
|
|
)
|
|
expect(redactKagiSessionToken('https://kagi.com/search/?token=secret&q=hi')).toBe(
|
|
'https://kagi.com/search/?q=hi'
|
|
)
|
|
})
|
|
})
|