feat: accept commonwealth spelling
This commit is contained in:
parent
8c7d34b5dd
commit
55b0985cf9
2 changed files with 8 additions and 5 deletions
|
@ -3,3 +3,4 @@ skia
|
|||
usvg
|
||||
resvg
|
||||
indoc
|
||||
horizell
|
||||
|
|
12
src/main.rs
12
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue