Handbook
Glossary
remove-dot-segments ( path -- path' )
Vocabulary
urls
.
private
Inputs
path
an
object
Outputs
path'
an
object
Definition
USING:
kernel
sequences
splitting
;
IN:
urls.private
:
remove-dot-segments
( path -- path' )
[
"//"
split1
]
[
"/"
glue
]
while*
[
"/./"
split1
]
[
"/"
glue
]
while*
[
"/../"
split1
]
[
[
"/"
split1-last
drop
]
dip
"/"
glue
]
while*
"/.."
?tail
[
"/"
split1-last
drop
"/"
append
]
when
"../"
?head
[
"/"
prepend
]
when
"./"
?head
[
"/"
prepend
]
when
"/."
?tail
[
"/"
append
]
when
[
"/"
]
when-empty
;