What is @smithy/util-uri-escape?
@smithy/util-uri-escape is a utility package designed to handle URI escaping and unescaping. It provides functions to ensure that URIs are properly encoded and decoded, which is essential for web development and API interactions.
What are @smithy/util-uri-escape's main functionalities?
escapeUri
The `escapeUri` function takes a URI string and returns an escaped version of it, ensuring that all special characters are properly encoded.
const { escapeUri } = require('@smithy/util-uri-escape');
const escapedUri = escapeUri('https://example.com/path?query=param');
console.log(escapedUri);
escapeUriPath
The `escapeUriPath` function specifically escapes the path component of a URI, making sure that spaces and special characters are encoded correctly.
const { escapeUriPath } = require('@smithy/util-uri-escape');
const escapedUriPath = escapeUriPath('/path with spaces/and special characters');
console.log(escapedUriPath);
Other packages similar to @smithy/util-uri-escape
querystring
The `querystring` package provides utilities for parsing and formatting URL query strings. It includes methods like `escape` and `unescape` for encoding and decoding URI components. Compared to @smithy/util-uri-escape, `querystring` offers a broader range of query string manipulation functions.
url
The `url` module in Node.js provides utilities for URL resolution and parsing. It includes methods like `url.format` and `url.parse` which handle URI encoding and decoding. While `url` is more comprehensive in terms of URL manipulation, @smithy/util-uri-escape focuses specifically on URI escaping.
encodeurl
The `encodeurl` package is a simple utility for URL encoding. It ensures that the URL is properly encoded, similar to the `escapeUri` function in @smithy/util-uri-escape. However, `encodeurl` is more lightweight and focused solely on encoding URLs.