# path-utils

URL path segment joining utilities.

> **Note:** This module works with URL-style paths, not filesystem paths. The output always has a leading and trailing `/`.

---

## `join(...path) → string`

Joins any number of URL path segments into a single normalised path string.

### Parameters

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `...path` | `string[]` | *(variadic)* | One or more path segments to join. Each segment may contain `/` characters and leading/trailing slashes are stripped before joining. |

### Returns

`string` — The joined path. Always starts and ends with `/` unless the result is empty.

### Example

```typescript
import { join } from '@yaoc1996/js-tools'

join()                   // ""
join("foo")              // "/foo/"
join("foo", "bar")       // "/foo/bar/"
join("/foo/", "/bar/")   // "/foo/bar/"  — redundant slashes stripped
join("a/b", "c/d")       // "/a/b/c/d/" — internal slashes respected
join("", "foo")          // "/foo/"      — empty segments skipped
join("foo//bar")         // "/foo/bar/"  — consecutive slashes collapsed
```

### Notes

- Returns an empty string `""` when called with no arguments or with only empty/slash segments.
- Designed for URL path construction (e.g. API routes), not for OS filesystem paths. Use Node.js `path.join` for filesystem paths.
- The trailing slash is intentional and consistent — all returned paths except the empty case end with `/`.
