mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-20 03:51:01 +08:00
Fix preset publication, volatile settings and client form binding
This commit is contained in:
parent
fe0fe70d33
commit
0b9a3a82bc
66 changed files with 8546 additions and 3690 deletions
19
tests/api-url-field.test.mjs
Normal file
19
tests/api-url-field.test.mjs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { apiUrlField } from '../src/client/card-form.ts'
|
||||
|
||||
test('apiUrlField accepts http(s) and normalizes trailing slash', () => {
|
||||
const field = apiUrlField('apiUrl')
|
||||
assert.deepEqual(field.parse('http://127.0.0.1:8890/'), {
|
||||
kind: 'set',
|
||||
value: 'http://127.0.0.1:8890',
|
||||
})
|
||||
assert.deepEqual(field.parse(''), { kind: 'clear' })
|
||||
})
|
||||
|
||||
test('apiUrlField rejects unsafe URLs', () => {
|
||||
const field = apiUrlField('apiUrl')
|
||||
assert.equal(field.parse('file:///tmp'), undefined)
|
||||
assert.equal(field.parse('http://user:pass@h/'), undefined)
|
||||
assert.equal(field.parse('not-a-url'), undefined)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue