# roomEndpoint

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/index/functions/roomendpoint/

## Call Signature

```ts
function roomEndpoint(room): string;
```

Defined in: [relay-sdks/ts/src/room-endpoint.ts:65](https://github.com/caprids/relay-sdks/blob/main/ts/src/room-endpoint.ts#L65)

Root an endpoint at a room. The result is the endpoint with each room field appended to its
path, after any path it has and without its trailing slashes, and with its query kept, a `jwt`
parameter included. A connection to it names namespaces relative to the room. Without an
endpoint it roots [DEFAULT\_ENDPOINT](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/variables/default_endpoint/):

```ts
roomEndpoint(['acme', 'rooms', '42']);
// 'https://relay.mux.global/acme/rooms/42'
roomEndpoint('https://relay.example', ['acme', 'rooms', '42']);
// 'https://relay.example/acme/rooms/42'
```

The endpoint follows the connect calls' rules and the room the namespace rules. Nothing is
percent-encoded: a room field holds only `A`–`Z`, `a`–`z`, `0`–`9` and `-._~!$&'()+,;=:@`, and is
not `.` or `..`. A namespace with any other field is reached from the bare host instead.

### Parameters

| Parameter | Type |
| ------ | ------ |
| `room` | readonly `string`[] |

### Returns

`string`

### Throws

An endpoint that is not an absolute URL string, or a room that is not a
sequence of non-empty string fields.

### Throws

An endpoint that is not `https`, has a fragment or userinfo, or an empty
`jwt`; a room of more than 32 fields; a room field with any other character, or `.` or `..`.

## Call Signature

```ts
function roomEndpoint(endpoint, room): string;
```

Defined in: [relay-sdks/ts/src/room-endpoint.ts:66](https://github.com/caprids/relay-sdks/blob/main/ts/src/room-endpoint.ts#L66)

Root an endpoint at a room. The result is the endpoint with each room field appended to its
path, after any path it has and without its trailing slashes, and with its query kept, a `jwt`
parameter included. A connection to it names namespaces relative to the room. Without an
endpoint it roots [DEFAULT\_ENDPOINT](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/variables/default_endpoint/):

```ts
roomEndpoint(['acme', 'rooms', '42']);
// 'https://relay.mux.global/acme/rooms/42'
roomEndpoint('https://relay.example', ['acme', 'rooms', '42']);
// 'https://relay.example/acme/rooms/42'
```

The endpoint follows the connect calls' rules and the room the namespace rules. Nothing is
percent-encoded: a room field holds only `A`–`Z`, `a`–`z`, `0`–`9` and `-._~!$&'()+,;=:@`, and is
not `.` or `..`. A namespace with any other field is reached from the bare host instead.

### Parameters

| Parameter | Type |
| ------ | ------ |
| `endpoint` | `string` |
| `room` | readonly `string`[] |

### Returns

`string`

### Throws

An endpoint that is not an absolute URL string, or a room that is not a
sequence of non-empty string fields.

### Throws

An endpoint that is not `https`, has a fragment or userinfo, or an empty
`jwt`; a room of more than 32 fields; a room field with any other character, or `.` or `..`.
