Function addLeadingSlash

  • Adds a leading slash to the beginning of the segment (if it doesn't already exist)

    Parameters

    • segment: string

    Returns string

    const segment = addLeadingSlash('example');

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