mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 13:23:35 +00:00
fix: ensure well formed URLs for IP address destinations
This commit is contained in:
committed by
Carlos Valente
parent
cbc03c898c
commit
e488ad19b3
@@ -175,7 +175,7 @@ describe('generateUrlPresetOptions', () => {
|
||||
expect(() => generateUrlPresetOptions('test', 'invalid-url')).toThrow();
|
||||
});
|
||||
|
||||
it('throws on on invalid route', () => {
|
||||
it('throws on invalid route', () => {
|
||||
expect(() => generateUrlPresetOptions('test', 'www.getontime.no/somethingelse/')).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,12 +14,18 @@ export default function GenerateLinkFormExport({ lockedPath }: GenerateLinkFormE
|
||||
const { data: infoData } = useInfo();
|
||||
const { data: urlPresetData } = useUrlPresets({ skip: lockedPath === undefined });
|
||||
|
||||
/**
|
||||
* hostOptions are only used for local networks
|
||||
* the NIF address is a local IP address: 192.168.x.x or 10.x.x.x
|
||||
* We need to inject the port and protocol to create a valid URL
|
||||
* eg: http://192.168.x.x:port
|
||||
*/
|
||||
const hostOptions = useMemo(() => {
|
||||
return infoData.networkInterfaces.map((nif) => ({
|
||||
value: nif.address,
|
||||
value: `http://${nif.address}:${infoData.serverPort}`,
|
||||
label: `${nif.name} - ${nif.address}`,
|
||||
}));
|
||||
}, [infoData.networkInterfaces]);
|
||||
}, [infoData.networkInterfaces, infoData.serverPort]);
|
||||
|
||||
const pathOptions = useMemo(() => {
|
||||
if (lockedPath) {
|
||||
|
||||
Reference in New Issue
Block a user