feat: Basic to username

This commit is contained in:
BluJ
2023-05-04 16:42:42 -06:00
parent 597aa48518
commit b9967023da
4 changed files with 12 additions and 8 deletions

View File

@@ -218,7 +218,7 @@ export type RandomString = {
len: number
}
// sometimes the type checker needs just a little bit of help
function isValueSpecListOf<S extends ListValueSpecType>(
export function isValueSpecListOf<S extends ListValueSpecType>(
t: ValueSpec,
s: S,
): t is ValueSpecListOf<S> & { spec: ListValueSpecOf<S> } {

View File

@@ -21,7 +21,7 @@ export class NetworkInterfaceBuilder {
id: string
description: string
ui: boolean
basic: null | { username: string }
username: null | string
path: string
search: Record<string, string>
},
@@ -36,10 +36,10 @@ export class NetworkInterfaceBuilder {
* @returns
*/
async export(origins: Iterable<Origin>) {
const { name, description, id, ui, basic, path, search } = this.options
const { name, description, id, ui, username, path, search } = this.options
const addresses = Array.from(origins).map((o) =>
o.build({ basic, path, search }),
o.build({ username, path, search }),
)
await this.options.effects.exportNetworkInterface({

View File

@@ -1,9 +1,9 @@
export class Origin {
constructor(readonly protocol: string | null, readonly host: string) {}
build({ basic, path, search }: BuildOptions) {
build({ username, path, search }: BuildOptions) {
// prettier-ignore
const urlAuth = !!(basic) ? `${basic.username}@` :
const urlAuth = !!(username) ? `${username}@` :
'';
const protocolSection = this.protocol != null ? `${this.protocol}://` : ""
@@ -20,7 +20,7 @@ export class Origin {
}
type BuildOptions = {
basic: { username: string } | null
username: string | null
path: string
search: Record<string, string>
}

View File

@@ -1,4 +1,8 @@
import { ListValueSpecOf, isValueSpecListOf } from "../config/configTypes"
import {
ListValueSpecOf,
ValueSpec,
isValueSpecListOf,
} from "../config/configTypes"
import { Config } from "../config/builder/config"
import { List } from "../config/builder/list"
import { Value } from "../config/builder/value"