Files
server/ui/src/url.ts
T
2023-09-21 19:44:46 +02:00

6 lines
352 B
TypeScript

const {port, hostname, protocol, pathname} = window.location;
const slashes = protocol.concat('//');
const path = pathname.endsWith('/') ? pathname : pathname.substring(0, pathname.lastIndexOf('/'));
const url = slashes.concat(port ? hostname.concat(':', port) : hostname) + path;
export const urlWithSlash = url.endsWith('/') ? url : url.concat('/');