Skip to main content

url_encode

Function url_encode 

Source
pub fn url_encode(input: &str) -> String
Expand description

URL-encodes a string using percent-encoding.

This function encodes special characters in a string to make it safe for use in URLs. It follows the percent-encoding scheme defined in RFC 3986.

§Parameters

  • input: The string to encode

§Returns

A URL-encoded string where special characters are replaced with %XX sequences

§Examples

use ignitia::utils::url_encode;

assert_eq!(url_encode("Hello World"), "Hello%20World");
assert_eq!(url_encode("user@example.com"), "user%40example.com");
assert_eq!(url_encode("price: $10.99"), "price%3A%20%2410.99");