uri
- Description:
- Provides methods for URI encoding and decoding. This namespace includes functions to safely encode and decode strings for use in URIs, ensuring that special characters are properly handled. It is useful for preparing data to be included in URLs, query parameters, or path segments
Methods
(static) decode(encodedString) → {string}
- Description:
- Decodes a URI-encoded string.
Example
const decoded = uri.decode('Hello%2C%20World%21');
console.log(decoded); // Outputs: Hello, World!
Parameters:
Name | Type | Description |
---|---|---|
encodedString |
string | The encoded string to decode. |
Returns:
The decoded string.
- Type
- string
(static) encode(inputString) → {string}
- Description:
- Encodes a string for use in a URI.
Example
const encoded = uri.encode('Hello, World!');
console.log(encoded); // Outputs: Hello%2C%20World%21
Parameters:
Name | Type | Description |
---|---|---|
inputString |
string | The string to encode. |
Returns:
The encoded URI component.
- Type
- string