mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
20 lines
528 B
TypeScript
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}`
|
|
}
|
|
}
|