mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-11-09 17:06:13 -06:00
51 lines
1005 B
JavaScript
51 lines
1005 B
JavaScript
import t from 'tap'
|
|
|
|
import parseUrl from './_parseUrl.mjs'
|
|
|
|
const data = {
|
|
'xcp.company.lan': {
|
|
hostname: 'xcp.company.lan',
|
|
pathname: '/',
|
|
protocol: 'https:',
|
|
},
|
|
'[::1]': {
|
|
hostname: '[::1]',
|
|
pathname: '/',
|
|
protocol: 'https:',
|
|
},
|
|
'http://username:password@xcp.company.lan': {
|
|
auth: 'username:password',
|
|
hostname: 'xcp.company.lan',
|
|
password: 'password',
|
|
pathname: '/',
|
|
protocol: 'http:',
|
|
username: 'username',
|
|
},
|
|
'https://username@xcp.company.lan': {
|
|
auth: 'username',
|
|
hostname: 'xcp.company.lan',
|
|
pathname: '/',
|
|
protocol: 'https:',
|
|
username: 'username',
|
|
},
|
|
}
|
|
|
|
t.test('invalid url', function (t) {
|
|
t.throws(() => parseUrl(''))
|
|
t.end()
|
|
})
|
|
|
|
for (const url of Object.keys(data)) {
|
|
t.test(url, function (t) {
|
|
const parsed = parseUrl(url)
|
|
for (const key of Object.keys(parsed)) {
|
|
if (parsed[key] === undefined) {
|
|
delete parsed[key]
|
|
}
|
|
}
|
|
|
|
t.same(parsed, data[url])
|
|
t.end()
|
|
})
|
|
}
|