diff --git a/.config/cspell/dictionary.txt b/.config/cspell/dictionary.txt index e830248..e47274c 100644 --- a/.config/cspell/dictionary.txt +++ b/.config/cspell/dictionary.txt @@ -3,3 +3,4 @@ skia usvg resvg indoc +horizell diff --git a/src/main.rs b/src/main.rs index efe03c5..b3808b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,10 +55,11 @@ fn main() { GET /icons/[icon].png - Get an icon rendered in PNG format Query parameters: -- note: Make sure to URL encode the query parameters: particularly special characters such as # (e.g. %23). The server only accepts a small subset of characters deemed necessary for the query parameters. + -- note: You may choose to use either colour or color (Commonwealth or US spelling) in the query parameters. Both are accepted. Specifying both will result in undefined behaviour, so don't do that! scale - integer - Scale the icon (default: 1, min: 1, max: 100) padding - integer - Add padding (px) around the icon (default: 0, min: 0, max: 100) background - hex - Set the background color in hex WITHOUT the hashtag (e.g. FFFFFF) (default: transparent) - stroke_color - string - Set the stroke color for the SVG icon, any CSS color WITH the hashtag (default: currentColor) + stroke_colour - string - Set the stroke color for the SVG icon, any CSS color WITH the hashtag (default: currentColor) discord_compatibility - boolean - Set padding to 8px for Discord compatibility. Typically for use in embed author icons as these have a circle clip applied by Discord. Overrides padding if set. (default: false) cache_key - string - Technically this can have any name. The server does not interpret this at all. Useful for cache busting. (default: none) Example: @@ -194,10 +195,11 @@ fn main() { } let mut svg_stroke = "currentColor"; - match req.url.query.get("stroke_color") { - Some(svg_stroke_str) => svg_stroke = svg_stroke_str, - None => {} - } + // thx horizell for this code + match (req.url.query.get("stroke_color"), req.url.query.get("stroke_colour")) { + (Some(stroke_str), _) | (_, Some(stroke_str)) => svg_stroke = stroke_str, + _ => {} + } icon_string = icon_string.replace("currentColor", &svg_stroke);