embedding-ollama-url.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * Ollama embed base URL validation (no network): prevents Undici "Invalid URL" from malformed OLLAMA_URL. |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert'; |
| 6 | import { normalizeOllamaEmbedBaseUrl } from '../lib/embedding.mjs'; |
| 7 | |
| 8 | describe('normalizeOllamaEmbedBaseUrl', () => { |
| 9 | it('accepts http localhost with port', () => { |
| 10 | assert.strictEqual(normalizeOllamaEmbedBaseUrl('http://localhost:11434'), 'http://localhost:11434'); |
| 11 | assert.strictEqual(normalizeOllamaEmbedBaseUrl('http://localhost:11434/'), 'http://localhost:11434'); |
| 12 | }); |
| 13 | |
| 14 | it('accepts https host', () => { |
| 15 | assert.strictEqual(normalizeOllamaEmbedBaseUrl('https://ollama.example.com'), 'https://ollama.example.com'); |
| 16 | assert.strictEqual(normalizeOllamaEmbedBaseUrl(' https://ollama.example.com/ '), 'https://ollama.example.com'); |
| 17 | }); |
| 18 | |
| 19 | it('uses default when null or empty string', () => { |
| 20 | assert.strictEqual(normalizeOllamaEmbedBaseUrl(null), 'http://localhost:11434'); |
| 21 | assert.strictEqual(normalizeOllamaEmbedBaseUrl(''), 'http://localhost:11434'); |
| 22 | }); |
| 23 | |
| 24 | it('rejects host without scheme', () => { |
| 25 | assert.throws( |
| 26 | () => normalizeOllamaEmbedBaseUrl('localhost:11434'), |
| 27 | /absolute http\(s\) URL/i, |
| 28 | ); |
| 29 | assert.throws( |
| 30 | () => normalizeOllamaEmbedBaseUrl('api.ollama.com'), |
| 31 | /absolute http\(s\) URL/i, |
| 32 | ); |
| 33 | }); |
| 34 | |
| 35 | it('rejects whitespace-only', () => { |
| 36 | assert.throws( |
| 37 | () => normalizeOllamaEmbedBaseUrl(' '), |
| 38 | /empty after trim/i, |
| 39 | ); |
| 40 | }); |
| 41 | |
| 42 | it('rejects non-http protocols', () => { |
| 43 | assert.throws( |
| 44 | () => normalizeOllamaEmbedBaseUrl('ftp://example.com'), |
| 45 | /starting with http:\/\/ or https:\/\//, |
| 46 | ); |
| 47 | }); |
| 48 | }); |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago