Files
start-sdk/lib/mainFn/Origin.ts
2023-05-01 13:04:48 -06:00

19 lines
443 B
TypeScript

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