express-joi-simple
Version:
## Installation
16 lines (15 loc) • 497 B
text/typescript
export function regexpToPath(thing: any) {
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')
: '<complex:' + thing.toString() + '>'
}
}