Function removeLeadingAndTrailingSlash

  • Removes the leading and trailing slash from the segment (if they exist)

    Parameters

    • segment: string

    Returns string

    const segment = removeLeadingAndTrailingSlash('/example/');

    console.log(segment); // 'example'