Skip to content

HTTP Utilities

A selection of utilities to help with common HTTP-related tasks in JavaScript and TypeScript projects.

Functions

addTrailingSlash()

addTrailingSlash(url): string

Defined in: http.utils.ts:11

Adds a trailing slash to the URL if it doesn’t have one.

Parameters

url

string

The URL to add a trailing slash to.

Returns

string

The URL with a trailing slash.

Example

addTrailingSlash('https://example.com'); // 'https://example.com/'
addTrailingSlash('https://example.com/'); // 'https://example.com/'