ParsedUrlURL 解析结果接口。
interface ParsedUrl {
/** 完整的原始 URL */
href: string
/** 协议 (http:, https:, etc.) */
protocol: string
/** 主机名 + 端口 */
host: string
/** 主机名 */
hostname: string
/** 端口号 */
port: string
/** 路径部分 */
pathname: string
/** 查询字符串 (包含 ?) */
search: string
/** 哈希部分 (包含 #) */
hash: string
/** 用户认证信息 (user:pass) */
auth: string
/** 源 (protocol + host) */
origin: string
}
import type { ParsedUrl } from '@movk/core'
import { parseUrl } from '@movk/core'
const result: ParsedUrl | null = parseUrl('https://example.com/path')
QueryParamValue查询参数值类型。
type QueryParamValue = string | number | boolean | null | undefined
import type { QueryParamValue } from '@movk/core'
const value: QueryParamValue = 'hello'
const numValue: QueryParamValue = 123
const boolValue: QueryParamValue = true
QueryParams查询参数对象类型。
type QueryParams = Record<string, QueryParamValue | QueryParamValue[]>
import type { QueryParams } from '@movk/core'
const params: QueryParams = {
page: 1,
limit: 10,
tags: ['a', 'b', 'c'],
active: true,
}