docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility that encodes URL parameters according to RFC 3986 standards for use in OAuth and other security-sensitive contexts.
{ user: "john@example.com", message: "Hello World!" }, the encoded query string is user=john%40example.com&message=Hello%20World%21 @test{ callback: "http://example.com/auth?token=abc123" }, the encoded query string is callback=http%3A%2F%2Fexample.com%2Fauth%3Ftoken%3Dabc123 @test"hello(world)", the encoded result is "hello%28world%29" @test"user's data", the encoded result is "user%27s%20data" @test"test*value!", the encoded result is "test%2Avalue%21" @test"私のさえずり" (Japanese text), the encoded result is "%E7%A7%81%E3%81%AE%E3%81%95%E3%81%88%E3%81%9A%E3%82%8A" @test{ text: "Café ☕" }, the encoded query string is text=Caf%C3%A9%20%E2%98%95 @test/**
* Encodes a string according to RFC 3986 percent-encoding rules.
* Encodes all characters that encodeURIComponent encodes, plus: ! * ( ) '
*
* @param {string} str - The string to encode
* @returns {string} The RFC 3986 percent-encoded string
*/
function encodeRFC3986(str) {
// IMPLEMENTATION HERE
}
/**
* Encodes an object of parameters into a query string with RFC 3986 encoding.
* Keys and values are sorted alphabetically by key name.
*
* @param {Object} params - Object with string keys and string values
* @returns {string} Encoded query string in format "key1=value1&key2=value2"
*/
function encodeParams(params) {
// IMPLEMENTATION HERE
}
module.exports = {
encodeRFC3986,
encodeParams,
};Provides RFC 3986 percent-encoding support for OAuth-compliant URL encoding.