def path.normalize
import bend-kit-files@0.3.1.0/files.bend as Filesimport Base
82# Drops empty and "." segments and resolves "..", as POSIX normpath does
83# (RFC 3986 §5.2.4 for paths), but always to one leading "/".
84def path.normalize(+p: String) -> String:
85 +abs = path.is_absolute(p)
86 path.norm.fin(abs,
87 String.join(List.reverse(&2, String,
88 path.norm.go(String.split(p, '/'), Nil{}, abs)), "/"))