Skip to content

Instantly share code, notes, and snippets.

@arn-ob
Created February 15, 2019 05:15
Show Gist options
  • Save arn-ob/6b3cc660a5a527cdc304af6cd56cea3c to your computer and use it in GitHub Desktop.
Save arn-ob/6b3cc660a5a527cdc304af6cd56cea3c to your computer and use it in GitHub Desktop.
function split (thing) {
if (typeof thing === 'string') {
return thing.split('/')
} else if (thing.fast_slash) {
return ''
} else {
var match = thing.toString()
.replace('\\/?', '')
.replace('(?=\\/|$)', '$')
.match(/^\/\^((?:\\[.*+?^${}()|[\]\\\/]|[^.*+?^${}()|[\]\\\/])*)\$\//)
return match
? match[1].replace(/\\(.)/g, '$1').split('/')
: '<complex:' + thing.toString() + '>'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment