function toUserDomain

Check hostname subdomain against UserDomain.

Examples

Valid user domain

import { toUserDomain } from './user_utils.ts'

const userDomain = toUserDomain('john-doe')
console.assert(userDomain === 'john-doe')

Invalid user domain

import { toUserDomain } from './user_utils.ts'

try {
	const userDomain = toUserDomain('johndont')
} catch (error) {
	console.assert(error instanceof Error)
}

Parameters

userDomain: string

Hostname to assert.

Return Type

Asserted user domain.

Usage

import { toUserDomain } from "user_utils.ts";