A Capacitor shell that opens a Sonda server in a WebView. It asks for the address of the server the first time and remembers it, trusts the certificate authorities installed on the phone, and keeps a notification with the controls so that the music goes on with the screen off. Fixes #47
23 lines
1 KiB
JavaScript
23 lines
1 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { test } from 'node:test'
|
|
import { normalizeAddress } from '../www/server.js'
|
|
|
|
test('a bare host gets https', () => {
|
|
assert.equal(normalizeAddress('music.example.org'), 'https://music.example.org')
|
|
})
|
|
|
|
test('a scheme that was typed is kept, and so is the port', () => {
|
|
assert.equal(normalizeAddress('http://192.168.1.5:8080'), 'http://192.168.1.5:8080')
|
|
assert.equal(normalizeAddress('https://music.example.org:8443'), 'https://music.example.org:8443')
|
|
})
|
|
|
|
test('spaces, a trailing slash, a path and a query are dropped', () => {
|
|
assert.equal(normalizeAddress(' https://music.example.org/ '), 'https://music.example.org')
|
|
assert.equal(normalizeAddress('https://music.example.org/albums/3?x=1#top'), 'https://music.example.org')
|
|
})
|
|
|
|
test('nothing, or something that is not an address, is refused', () => {
|
|
for (const bad of ['', ' ', null, undefined, 'ftp://music.example.org', 'http://', 'not an address']) {
|
|
assert.equal(normalizeAddress(bad), null, String(bad))
|
|
}
|
|
})
|