Function addLeadingSlash

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

const segment = addLeadingSlash('example');

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

    • segment: string

    Returns string