Skip to content

Instantly share code, notes, and snippets.

@jlord
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlord/0dcf81f1c7030bbbf336 to your computer and use it in GitHub Desktop.
Save jlord/0dcf81f1c7030bbbf336 to your computer and use it in GitHub Desktop.
var path = 'atom-electron-b4403fa/docs/api/accelerator.md'
// wanted: 'docs/latest/api/accelerator'
// - add 'latest/' after 'docs/'
// - remove 'atom-electron-b443fa'
// - remove file extension at the end
function constructRedirectUrl (path) {
var a = path.split('/')
a.splice(2, 0, 'latest').splice(0, 1)
var c = a.join('/')
var d = c.split('.')
return d.shift()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment