Function removeTrailingSlash

  • Removes trailing slashes from a given string.

    Example

    Here is a simple example:

    removeTrailingSlash("https://example.com/")
    // => { ok: true, value: 'http://example.com' }

    removeTrailingSlash("https://example.com/path/")
    // => { ok: true, value: 'https://example.com/path' }

    Example

    Handling non-string input:

    removeTrailingSlash(42)
    // => { ok: false, error: Error('[strings.removeTrailingSlash] Expected string value as input') }

    Parameters

    • str: string

      The string to remove trailing slashes from.

    Returns Result<string, Error>

    A Result object with either the modified string on success, or an Error object if the provided input is not a string.

Generated using TypeDoc v0.24.7