A set of TypeScript type definitions describing URL structure and parse results, covering fields such as protocol, host, and pathname.
ParsedUrl
The URL parse result interface.
interface ParsedUrl {
/** The full original URL */
href: string
/** Protocol (http:, https:, etc.) */
protocol: string
/** Hostname + port */
host: string
/** Hostname */
hostname: string
/** Port number */
port: string
/** Pathname portion */
pathname: string
/** Query string (includes ?) */
search: string
/** Hash portion (includes #) */
hash: string
/** User authentication info (user:pass) */
auth: string
/** Origin (protocol + host) */
origin: string
}
Usage
import type { ParsedUrl } from '@movk/core'
import { parseUrl } from '@movk/core'
const result: ParsedUrl | null = parseUrl('https://example.com/path')
QueryParamValue
Query parameter value type.
type QueryParamValue = string | number | boolean | null | undefined
Usage
import type { QueryParamValue } from '@movk/core'
const value: QueryParamValue = 'hello'
const numValue: QueryParamValue = 123
const boolValue: QueryParamValue = true
QueryParams
Query parameters object type.
type QueryParams = Record<string, QueryParamValue | QueryParamValue[]>
Usage
import type { QueryParams } from '@movk/core'
const params: QueryParams = {
page: 1,
limit: 10,
tags: ['a', 'b', 'c'],
active: true,
}
Changelog
No recent changes