@finsweet/ts-utils
Version:
Typescript utils for custom Webflow projects.
17 lines (16 loc) • 403 B
JavaScript
/**
* Removes the trailing slash from a URL string.
*
* @example
* ```
* This:
* https://www.finsweet.com/attributes/attractions/capri-island/
*
* Becomes:
* https://www.finsweet.com/attributes/attractions/capri-island
* ```
*
* @param value The value to mutate.
* @returns A new string without a trailing slash.
*/
export const removeTrailingSlash = (value) => value.replace(/\/+$/, '');