[turbopack] Rename variables in `path_join` and add tests (#94625)
`results` became `segments` and `results_final` became `locked_prefix`,
the `segments` name I'm not too attached to, I'm just trying to
communicate that that vector stores the "other" parts of the path that
aren't fixed and can change. Meanwhile, the `locked_prefix` has to be at
the start - it contains variables we don't know the value of (and
anything that came before it) or also the starting "." or "..". I think
this is what "final" was originally trying to communicate.
I also had Claude generate tests for this function based on the
pre-existing tests in the `node` repo. There was some divergence related
to absolute paths if anyone is curious:
| Input | turbopack | node |
|---|---|---|
| `["", "foo"]` | `/foo` | `foo` |
| `["", "", "foo"]` | `/foo` | `foo` |
| `["", "..", "..", "/foo"]` | `/../../foo` | `../../foo` |
| `["/"]` | `` (empty) | `/` |
| `["/", "."]` | `` (empty) | `/` |
| `["/foo", "../../../bar"]` | `/../../bar` | `/bar` |
| `["/", ".."]` | `/..` | `/` |
| `["/", "..", ".."]` | `/../..` | `/` |
| `["", "."]` | `` (empty) | `.` |
| `[""]` | `` (empty) | `.` |
| `["", ""]` | `` (empty) | `.` |
I can follow-up and fix these as well if that'd be worthwhile, though I
think it was mentioned that we don't support absolute paths