---
title: "normalizeUrl"
description: "Normalize a URL path by removing redundant slashes and resolving dot and double-dot segments, producing a clean canonical form."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/url/normalize-url"
---
# normalizeUrl

> Normalize a URL path by removing redundant slashes and resolving dot and double-dot segments, producing a clean canonical form.

## Usage

`normalizeUrl` normalizes a URL path by removing redundant slashes and resolving `.` and `..` segments.

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

Normalize a URL path.

### Parameters

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

### Returns

**returns** (`string`): The normalized URL.

## 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.
