Files
start-sdk/lib/mainFn/Origin.ts
2023-05-02 16:47:37 -06:00

20 lines
528 B
TypeScript

export class Origin {
constructor(readonly protocol: string | null, readonly host: string) {}
withAuth(
origin?:
| {
password: null | string
username: string
}
| null
| undefined,
) {
// prettier-ignore
const urlAuth = !!(origin) ? `${origin.username}${origin.password != null ?`:${origin.password}`:''}@` :
'';
const protocolSection = this.protocol != null ? `${this.protocol}://` : ""
return `${protocolSection}${urlAuth}${this.host}`
}
}