UNPKG
shifty-router
Version:
latest (1.0.0)
1.0.0
0.1.1
0.1.0
Fast, modular client router
github.com/lorengreenfield/shifty-router
lorengreenfield/shifty-router
shifty-router
/
_pathname.js
8 lines
(7 loc)
•
299 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
export
default
function
pathname
(
route
) {
if
(
typeof
route !==
'string'
)
return
'/'
var
path = route.
replace
(
/^(http[s]?:\/\/[^/]+)/
,
''
)
// Strip protocol and domain
path = path.
replace
(
/[?#].*$/
,
''
)
// Strip query and hash
if
(!path || path[
0
] !==
'/'
) path =
'/'
+ path
return
path }