> For the complete documentation index, see [llms.txt](https://funkcia.lukemorales.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://funkcia.lukemorales.io/modules/uri.md).

# URI

Funkcia provides a safe `URI` module to work with URI encoding/decoding without breaking your application.

## SafeURI

SafeURI provides safe wrappers around JavaScript's native URI encoding/decoding functions, returning `Result` types instead of throwing exceptions, preserving all signature overloads of the original namespace.

#### encode

Encodes a text string as a valid Uniform Resource Identifier (URI).

```typescript
import { SafeURI } from 'funkcia/uri';

//      ┌─── Result<string, URIError>
//      ▼
const result = SafeURI.encode('https://example.com/path with spaces');
// Output: Ok('https://example.com/path%20with%20spaces')
```

#### decode

Gets the unencoded version of an encoded Uniform Resource Identifier (URI).

```typescript
import { SafeURI } from 'funkcia/uri';

//      ┌─── Result<string, URIError>
//      ▼
const result = SafeURI.decode('https://example.com/path%20with%20spaces');
// Output: Ok('https://example.com/path with spaces')
```

#### encodeURIComponent

Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

```typescript
import { SafeURI } from 'funkcia/uri';

//      ┌─── Result<string, URIError>
//      ▼
const result = SafeURI.encodeURIComponent('path/with/slashes');
// Output: Ok('path%2Fwith%2Fslashes')
```

#### decodeURIComponent

Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).

```typescript
import { SafeURI } from 'funkcia/uri';

//      ┌─── Result<string, URIError>
//      ▼
const result = SafeURI.decodeURIComponent('path%2Fwith%2Fslashes');
// Output: Ok('path/with/slashes')
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://funkcia.lukemorales.io/modules/uri.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
