---
title: "removeTrailingSlash"
description: "Remove a trailing slash from a URL and return a new string, normalizing links so identical routes are not duplicated."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/url/remove-trailing-slash"
---
# removeTrailingSlash

> Remove a trailing slash from a URL and return a new string, normalizing links so identical routes are not duplicated.

## Usage

`removeTrailingSlash` removes the trailing slash from a URL.

```ts
import { removeTrailingSlash } from '@movk/core'

removeTrailingSlash('https://example.com/') // 'https://example.com'
removeTrailingSlash('https://example.com/path/') // 'https://example.com/path'
removeTrailingSlash('https://example.com') // 'https://example.com'
```

## API

### `removeTrailingSlash(url)`

Remove the trailing slash from a URL.

### Parameters

**url** (`string`) *required*: The URL string.

### Returns

**returns** (`string`): The URL with the trailing slash 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.
