ensureTrailingSlash
Ensure a URL ends with a single trailing slash, adding one when missing so directory-style links resolve consistently.
Usage
ensureTrailingSlash ensures a URL ends with a trailing slash.
import { ensureTrailingSlash } from '@movk/core'
ensureTrailingSlash('https://example.com') // 'https://example.com/'
ensureTrailingSlash('https://example.com/path') // 'https://example.com/path/'
ensureTrailingSlash('https://example.com/') // 'https://example.com/'
API
ensureTrailingSlash(url)
Ensure a URL ends with a trailing slash.
Parameters
url
string required
The URL string.
Returns
returns
string
The URL with a trailing slash.
Changelog
No recent changes