encodeURIComponent

encodeURIComponent is a passthrough of the platform function, re-exported so the encode / decode pair lives in one import. Its companion decodeURIComponent is a safe variant that returns the input instead of throwing. Part of pota/use/url.

Arguments

Argument Type Description
string string The string to encode.

Returns: the percent-encoded string (identical to the platform encodeURIComponent).

Examples

Encode a value

Percent-encodes a string exactly like the platform function.

import { encodeURIComponent } from 'pota/use/url'

encodeURIComponent('a b') // 'a%20b'