You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setting a custom label for a status-badge, such as https://status.example.org/api/badge/47/status?label=foobar and the status is DOWN, this results in:
This even overrides the &downLabel=example property, so https://status.example.org/api/badge/47/status?label=foobar&downLabel=Down is not a workaround. The &upLabel=example works just fine though.
This only affects status-badges, not duration-badges.
The reason for this is this line - my suggestion would be to instead use badgeValues.message = state ? upLabel : downLabel;.
Explanation
The "?? state ? upLabel : downLabel" part of the line is called the "null coalescing operator" and the ternary operator.
The null coalescing operator (??) checks if the variable "label" is null or undefined, and if so, it assigns the value of "state" to "label".
Then, the ternary operator (?:) checks if the value of "label" is truthy or falsy, and assigns the value of "upLabel" if truthy, and "downLabel" if falsy.
So, if "label" is truthy, "message" will be set to "upLabel" and if "label" is falsy, "message" will be set to "downLabel".
This results in status being always overwritten as "truthy" or "up" when a label is set. This does not hold for the color, which is correctly assigned only based on status (badgeValues.color = state ? upColor : downColor;).
Happy to do a PR if it's welcome.
👟 Reproduction steps
Check the https://status.example.org/api/badge/47/status?label=foobar on your favorite Uptime-Kuma instance. Remember that you need to add the monitor (in this case e.g. 47) to a public status page in order for badges to work.
👀 Expected behavior
Passing the label in the URL should only modify the label on the left-side, not the message. I'd expect this: https://status.example.org/api/badge/47/status?label=foobar
->
😓 Actual Behavior
Passing the label in the URL modifies the label on the left-side and also sets the message, ignoring the status: https://status.example.org/api/badge/47/status?label=foobar
->
🐻 Uptime-Kuma Version
1.19.6
💻 Operating System and Arch
Debian 11 x64
🌐 Browser
Firefox 109.0
🐋 Docker Version
No response
🟩 NodeJS Version
No response
📝 Relevant log output
No response
The text was updated successfully, but these errors were encountered:
🛡️ Security Policy
Description
When setting a custom label for a status-badge, such as
https://status.example.org/api/badge/47/status?label=foobar
and the status is DOWN, this results in:This even overrides the
&downLabel=example
property, sohttps://status.example.org/api/badge/47/status?label=foobar&downLabel=Down
is not a workaround. The&upLabel=example
works just fine though.This only affects status-badges, not duration-badges.
The reason for this is this line - my suggestion would be to instead use
badgeValues.message = state ? upLabel : downLabel;
.Explanation
The "?? state ? upLabel : downLabel" part of the line is called the "null coalescing operator" and the ternary operator.The null coalescing operator (??) checks if the variable "label" is null or undefined, and if so, it assigns the value of "state" to "label".
Then, the ternary operator (?:) checks if the value of "label" is truthy or falsy, and assigns the value of "upLabel" if truthy, and "downLabel" if falsy.
So, if "label" is truthy, "message" will be set to "upLabel" and if "label" is falsy, "message" will be set to "downLabel".
This results in status being always overwritten as "truthy" or "up" when a label is set. This does not hold for the color, which is correctly assigned only based on status (
badgeValues.color = state ? upColor : downColor;
).Happy to do a PR if it's welcome.
👟 Reproduction steps
Check the
https://status.example.org/api/badge/47/status?label=foobar
on your favorite Uptime-Kuma instance. Remember that you need to add the monitor (in this case e.g. 47) to a public status page in order for badges to work.👀 Expected behavior
Passing the label in the URL should only modify the label on the left-side, not the message. I'd expect this:
https://status.example.org/api/badge/47/status?label=foobar
->
😓 Actual Behavior
Passing the label in the URL modifies the label on the left-side and also sets the message, ignoring the status:
https://status.example.org/api/badge/47/status?label=foobar
->
🐻 Uptime-Kuma Version
1.19.6
💻 Operating System and Arch
Debian 11 x64
🌐 Browser
Firefox 109.0
🐋 Docker Version
No response
🟩 NodeJS Version
No response
📝 Relevant log output
No response
The text was updated successfully, but these errors were encountered: