An open API service indexing awesome lists of open source software.

https://github.com/khaosdoctor/percent-encode

Percent encode string following Twitter's spec from RFC 3986
https://github.com/khaosdoctor/percent-encode

decoding encoding percent-encode

Last synced: 8 months ago
JSON representation

Percent encode string following Twitter's spec from RFC 3986

Awesome Lists containing this project

README

          

# percent-encode

> [Percent encode](https://developer.twitter.com/en/docs/authentication/oauth-1-0a/percent-encoding-parameters) strings

This implementation is following Twitter's spec from [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986#section-2.1).

**Disclaimer**: This module is made to work with Deno alone, it won't work in Node environments.

## Install

```ts
import { decode, encode } from 'https://deno.land/x/percentencode/mod.ts';
```

## Usage

The lib provides two functions: `encode` and `decode`.

### `encode`

Encode will take a string or a byte array and return a promise that will contain the percent-encoded string.

```ts
await encode('Hello World!'); // Hello%20World%21
```

### `decode`

Decode will take a string and return a promise that will contain the percent-decoded string.

```ts
await decode('Hello%20World%21'); // Hello World!
```