Created
February 15, 2019 05:15
-
-
Save arn-ob/6b3cc660a5a527cdc304af6cd56cea3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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