mvp-ai's picture
download
raw
1.02 kB
// Copyright (c) 2026 the Zuke contributors
// SPDX-License-Identifier: MIT
/**
* The one percent-encoder for what goes in a signed URL: RFC 3986 strict, so
* every byte but the unreserved `A–Z a–z 0–9 - . _ ~` is escaped, and a space
* is `%20`, never the form encoding's `+`.
*
* A transport that encodes a request's parameters with it and a signer that
* encodes the canonical query with it agree byte for byte on the URL: a `+`
* on the wire that one side reads as a space and the other as a plus is a
* signature that fails for some queries and not others.
*
* @module
*/
/** `value` percent-encoded per RFC 3986 (unreserved characters kept). */
export function uriEncode(value: string): string {
// A lone surrogate cannot be UTF-8 encoded; replace it as URLSearchParams
// would rather than throw a URIError over a stray character in a query.
return encodeURIComponent(value.toWellFormed()).replace(
/[!'()*]/g,
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
);
}

Xet Storage Details

Size:
1.02 kB
·
Xet hash:
4e97f76a6f2d6e4e781b141f2b821d2e6e3dd8a979560e4789b40b52357dca98

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.