Encode and decode URL components, build and parse query strings effortlessly.
import { url } from 'toolmetry';| Function | Parameters | Returns | Description |
|---|---|---|---|
url.encode | input: string | string | URL-encode a string |
url.decode | input: string | string | Decode a URL-encoded string |
url.buildQuery | params: Record<string, string|number|boolean> | string | Build a query string from an object |
url.parseQuery | qs: string | Record<string, string> | Parse a query string into an object |
import { url } from 'toolmetry';
const encoded = url.encode('hello world&foo=bar');
// "hello%20world%26foo%3Dbar"
const decoded = url.decode(encoded);
// "hello world&foo=bar"import { url } from 'toolmetry';
const qs = url.buildQuery({ name: 'John', age: 30, active: true });
// "?name=John&age=30&active=true"import { url } from 'toolmetry';
const params = url.parseQuery('?name=John&age=30');
// { name: "John", age: "30" }