normalizeUrl

规范化 URL 路径(移除多余斜杠、处理 . 和 ..)

用法

normalizeUrl 函数用于规范化 URL 路径(移除多余斜杠、处理 ...)。

import { normalizeUrl } from '@movk/core'

normalizeUrl('https://example.com//api///users/')
// 'https://example.com/api/users/'

normalizeUrl('https://example.com/api/../users')
// 'https://example.com/users'

normalizeUrl('/api/./users/../posts')
// '/api/posts'

API

normalizeUrl(url)

规范化 URL 路径。

参数

url
string required
URL 字符串。

返回值

返回值
string
规范化后的 URL。

Changelog

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

Copyright © 2024 - 2026 YiXuan - MIT License