removeLeadingSlash

Remove leading slashes from a path, returning a clean relative segment that is safe to join with other URL or route parts.

Usage

removeLeadingSlash removes leading slashes from a URL or path.

import { removeLeadingSlash } from '@movk/core'

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

API

removeLeadingSlash(url)

Remove leading slashes from a URL or path.

Parameters

url
string required
The URL or path string.

Returns

returns
string
The string with leading slashes removed.

Changelog

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