buildUrl

构建完整 URL

用法

buildUrl 函数用于构建完整 URL。

import { buildUrl } from '@movk/core'

buildUrl('https://example.com', '/api/users', { page: 1, limit: 10 })
// 'https://example.com/api/users?page=1&limit=10'

buildUrl('https://example.com', '/page', null, 'section')
// 'https://example.com/page#section'

buildUrl('https://example.com', '/api', { ids: [1, 2, 3] })
// 'https://example.com/api?ids=1&ids=2&ids=3'

API

buildUrl(base, path?, query?, hash?)

构建完整 URL。

参数

base
string required
基础 URL。
path
string
路径部分。
query
QueryParams | null
查询参数。
hash
string
哈希部分。

返回值

返回值
string
完整 URL。

Changelog

7c832 — refactor!: 重构模块架构,拆分 utils 为专业化模块

Copyright © 2024 - 2026 YiXuan - MIT License