# URL joiner

Resolve relative links such as ../page or ?q=1 against a base URL, following RFC 3986.

- Endpoint: `POST https://setget.net/v1/tools/url-join` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `url-join`
- Page: https://setget.net/tools/url-join

## Inputs

- `base` (required, string): The absolute URL the links are relative to.
- `references` (required, array): Relative or absolute links to resolve.

## Example 1: The examples from RFC 3986

```json
{"input":{"base":"http://a/b/c/d;p?q","references":["g","../g","/g","//g","?y","#s","../../../g"]}}
```

Result:

```json
{"base":"http://a/b/c/d;p?q","results":[{"reference":"g","url":"http://a/b/c/g"},{"reference":"../g","url":"http://a/b/g"},{"reference":"/g","url":"http://a/g"},{"reference":"//g","url":"http://g"},{"reference":"?y","url":"http://a/b/c/d;p?y"},{"reference":"#s","url":"http://a/b/c/d;p?q#s"},{"reference":"../../../g","url":"http://a/g"}]}
```

## Example 2

```json
{"input":{"base":"https://example.com/docs/guide/","references":["intro.html","../img/logo.png"]}}
```

Result:

```json
{"base":"https://example.com/docs/guide/","results":[{"reference":"intro.html","url":"https://example.com/docs/guide/intro.html"},{"reference":"../img/logo.png","url":"https://example.com/docs/img/logo.png"}]}
```

**Why does the last part of the base disappear?** A relative link replaces everything after the last slash of the base. End the base with a slash if its last part is a folder.
