Skip to content

Instantly share code, notes, and snippets.

@jankeesvw
Created June 26, 2012 20:22
Show Gist options
  • Save jankeesvw/2998661 to your computer and use it in GitHub Desktop.
Save jankeesvw/2998661 to your computer and use it in GitHub Desktop.
# if the input is a NavigationSate, make it an array
path = path.getSegments() if path instanceof NavigationState is true
# if the input is an array, join them with slashes
path = path.join('/') if Array.isArray(path)
# add a slash in the begin if it isn't present
path = '/' + path if path.charAt(0) isnt '/'
# add a slash at the end if it isn't present
path = path + '/' if path.charAt(path.length - 1) isnt '/'
# replace double slashes
path = path.replace(/\/+/g, '/')
# replace white spaces with dashes
path = path.replace(/\s/g, '-')
# save the validated value in the @path instance variable
@path = path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment