joinUrl

GitHub查看源码
将多个 URL 路径片段连接为一个规范化的路径字符串,自动处理斜杠分隔符。

用法

joinUrl 函数用于连接 URL 路径片段。

import { joinUrl } from '@movk/core'

joinUrl('https://example.com', 'api', 'users')
// 'https://example.com/api/users'

joinUrl('https://example.com/', '/api/', '/users/')
// 'https://example.com/api/users/'

joinUrl('/api', 'users', '123')
// '/api/users/123'

API

joinUrl(...parts)

连接 URL 路径片段。

参数

parts
string[] required
URL 片段。

返回值

返回值
string
连接后的 URL。

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License