pub fn slugify2(nickname: &str) -> Cow<'_, str>Expand description
Converts a nickname to a URL-safe slug format for API requests
This function handles special characters and non-ASCII characters in nicknames
by encoding them into a format that can be safely used in URLs. Characters that
are not ASCII or are in SLUGIFY_SYMBOLS are converted to their Unicode code points
surrounded by hyphens.
§Arguments
nickname- The player nickname to slugify
§Returns
Returns Cow<'_, str> - Borrowed if no conversion needed, Owned if conversion occurred
§Examples
use ddapi_rs::prelude::slugify2;
// ASCII-only nicknames without special symbols are returned as-is
assert_eq!(slugify2("Player1"), "Player1");
// Special symbols and non-ASCII characters are encoded
assert_eq!(slugify2("Player@"), "Player-64-");
assert_eq!(slugify2("玩家"), "-29609--23478-");
// Mixed characters
assert_eq!(slugify2("Test_Player"), "Test-95-Player");