mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
21 lines
660 B
TypeScript
21 lines
660 B
TypeScript
|
|
|
|
export function getServiceLink(ui_location: string): string {
|
|
// Check if the ui location is a valid URL
|
|
try {
|
|
const url = new URL(ui_location);
|
|
// If it is a valid URL, return it as is
|
|
return url.href;
|
|
} catch (e) {
|
|
// If it fails, it means it's not a valid URL
|
|
}
|
|
|
|
// Check if the ui location is a port number
|
|
const parsedPort = parseInt(ui_location, 10);
|
|
if (!isNaN(parsedPort)) {
|
|
// If it's a port number, return a link to the service on that port
|
|
return `http://${window.location.origin}:${parsedPort}`;
|
|
}
|
|
// Otherwise, treat it as a path
|
|
return `/${ui_location}`;
|
|
} |