removeLeadingSlash

GitHub查看源码
移除路径字符串的开头斜杠,若无则原样返回,常用于路径拼接前的预处理。

用法

removeLeadingSlash 函数用于移除 URL 的开头斜杠。

import { removeLeadingSlash } from '@movk/core'

removeLeadingSlash('/path/to/page') // 'path/to/page'
removeLeadingSlash('///path') // 'path'
removeLeadingSlash('path') // 'path'

API

removeLeadingSlash(url)

移除 URL 的开头斜杠。

参数

url
string required
URL 或路径字符串。

返回值

返回值
string
移除开头斜杠后的字符串。

Changelog

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