mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
feat: Origins can be null
This commit is contained in:
@@ -20,7 +20,7 @@ export const ipv6 = once(
|
|||||||
export const local = once(() => /\.local/)
|
export const local = once(() => /\.local/)
|
||||||
export class LocalBinding {
|
export class LocalBinding {
|
||||||
constructor(readonly localHost: string, readonly ipHosts: string[]) {}
|
constructor(readonly localHost: string, readonly ipHosts: string[]) {}
|
||||||
createOrigins(protocol: string) {
|
createOrigins(protocol: string | null) {
|
||||||
const ipHosts = this.ipHosts
|
const ipHosts = this.ipHosts
|
||||||
return {
|
return {
|
||||||
local: new Origin(protocol, this.localHost),
|
local: new Origin(protocol, this.localHost),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export class Origin {
|
export class Origin {
|
||||||
constructor(readonly protocol: string, readonly host: string) {}
|
constructor(readonly protocol: string | null, readonly host: string) {}
|
||||||
|
|
||||||
withAuth(
|
withAuth(
|
||||||
origin?:
|
origin?:
|
||||||
@@ -13,6 +13,7 @@ export class Origin {
|
|||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const urlAuth = !!(origin) ? `${origin.username}${origin.password != null ?`:${origin.password}`:''}@` :
|
const urlAuth = !!(origin) ? `${origin.username}${origin.password != null ?`:${origin.password}`:''}@` :
|
||||||
'';
|
'';
|
||||||
return `${this.protocol}://${urlAuth}${this.host}`
|
const protocolSection = this.protocol != null ? `${this.protocol}://` : ""
|
||||||
|
return `${protocolSection}${urlAuth}${this.host}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Origin } from "./Origin"
|
|||||||
|
|
||||||
export class TorBinding {
|
export class TorBinding {
|
||||||
constructor(readonly host: string) {}
|
constructor(readonly host: string) {}
|
||||||
createOrigin(protocol: string) {
|
createOrigin(protocol: string | null) {
|
||||||
return new Origin(protocol, this.host)
|
return new Origin(protocol, this.host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user