normalize

fun normalize()

Normalizes the segments of a URL path according to the following rules:

  • The returned path always begins with / (e.g., a/b/c/a/b/c)

  • The returned path ends with / if the input path also does

  • Empty segments are discarded (e.g., /a//b/a/b)

  • Segments of . are discarded (e.g., /a/./b/a/b)

  • Segments of .. are used to discard ancestor paths (e.g., /a/b/../c/a/c)

  • All other segments are unmodified