mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 09:53:48 +00:00
fix: ensure well formed URLs for IP address destinations
This commit is contained in:
committed by
Carlos Valente
parent
cbc03c898c
commit
e488ad19b3
@@ -80,6 +80,18 @@ describe('generateAuthenticatedUrl()', () => {
|
||||
});
|
||||
expect(withAuth.toString()).toBe('http://192.168.10.173:4001/?token=1234');
|
||||
});
|
||||
|
||||
it('throws if provided an IP address without protocol', () => {
|
||||
expect(() =>
|
||||
generateShareUrl('192.168.10.173', '<<companion>>', {
|
||||
lockConfig: false,
|
||||
lockNav: false,
|
||||
authenticate: true,
|
||||
preset: undefined,
|
||||
hash: '1234',
|
||||
}),
|
||||
).toThrowError('Invalid URL');
|
||||
});
|
||||
});
|
||||
|
||||
describe('for ontime-cloud URLs', () => {
|
||||
|
||||
@@ -62,6 +62,11 @@ export function generateShareUrl(
|
||||
canonicalPath: string,
|
||||
{ authenticate, lockConfig, lockNav, preset, prefix = routerPrefix, hash = hashedPassword }: LinkOptions,
|
||||
): URL {
|
||||
/**
|
||||
* URL constructor will throw if given an IP address without protocol
|
||||
* for the case of IP addresses, we expect that the base URL provides protocol and port
|
||||
* eg: http://192.168.10.1:4001
|
||||
*/
|
||||
const url = new URL(baseUrl);
|
||||
|
||||
// companion links point to the root
|
||||
|
||||
Reference in New Issue
Block a user