---
title: "removeLeadingSlash"
description: "Remove leading slashes from a path, returning a clean relative segment that is safe to join with other URL or route parts."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/url/remove-leading-slash"
---
# 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.

```ts
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

See commit history for [src/utilities/url/transform.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/utilities/url/transform.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/utilities/url/transform.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
