Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: handle monitor names with slashes #4472

Merged
merged 2 commits into from
Mar 3, 2024

Conversation

andipaetzold
Copy link
Contributor

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

On the details view, the group text above the monitor name is generated by checking for slashes in monitor.pathName. This causes issues when the monitor name contains a slash. E.g. for the name GitHub (/louislam) the group GitHub ( is detected.

What changed:

  • a new property path on Monitor that stores the path as an array
  • pathName is derived from path to not double the db requests

Type of change

Please delete any options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • User interface (UI)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Description Before After
No group, no slash image image
No group, one slash image image
No group, two slashes image image
Group, no slash image image
Group, one slash image image
Group, two slashes image image

@andipaetzold andipaetzold marked this pull request as ready for review February 9, 2024 22:09
Copy link
Collaborator

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foremost, good catch! That is something that we did not think about.
I think !this.monitor.pathName.includes("/") => group = "" is a sort of funny bug 😅

Overall, this looks good to me (I have left some syle-comments, but those may be ignored if you don't think they are valid)
Thanks for including all the screenshots in the description, they help a lot.

I am not quite thrilled about adding another field to the MonitorJSON, but after looking at the usage of pathName, I agree that this is the better choice ^^

server/model/monitor.js Show resolved Hide resolved
server/model/monitor.js Show resolved Hide resolved
server/model/monitor.js Outdated Show resolved Hide resolved
Co-authored-by: Frank Elsinga <frank@elsinga.de>
@andipaetzold
Copy link
Contributor Author

I updated the jsdoc and would not apply the other change as explained in the thread.

I am not quite thrilled about adding another field to the MonitorJSON, but after looking at the usage of pathName, I agree that this is the better choice ^^

We could remove pathName from the monitor model and use monitor.path.join(' / ') instead - but that would only spread complexity around the code-base.

@CommanderStorm
Copy link
Collaborator

but that would only spread complexity around the code-base

MonitorJSON is exported to notifications and may thus be used in templates
⇒ inlining would be a breaking change

I don't really see a benefit from doing so
⇒ I'd vote for keeping it as is

@louislam louislam added this to the 2.0.0 milestone Feb 10, 2024
@CommanderStorm CommanderStorm added the area:monitor Everything related to monitors label Feb 12, 2024
@louislam louislam merged commit a0c62d8 into louislam:master Mar 3, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:monitor Everything related to monitors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants