Deviopath › Node.js

path.posix.join

Medium · Paths

Implement joinPaths(segments) with exactly the same results as Node's path.posix.join(...segments).

Node does it in two steps:

1. Skip empty strings and glue the remaining segments together with /.

2. Normalize the result like path.posix.normalize: collapse repeated slashes, remove ., resolve .. (never above / for absolute paths, kept at the start for relative ones) and keep a trailing slash.

If nothing is left to join, the result is ".". Only the first non-empty segment decides whether the result is absolute.

Next: Decode a JWT