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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ class Monitor extends BeanModel {
screenshot = "/screenshots/" + jwt.sign(this.id, UptimeKumaServer.getInstance().jwtSecret) + ".png";
}

const path = await this.getPath();
const pathName = path.join(" / ");
andipaetzold marked this conversation as resolved.
Show resolved Hide resolved

let data = {
id: this.id,
name: this.name,
description: this.description,
pathName: await this.getPathName(),
path,
pathName,
CommanderStorm marked this conversation as resolved.
Show resolved Hide resolved
parent: this.parent,
childrenIDs: await Monitor.getAllChildrenIDs(this.id),
url: this.url,
Expand Down Expand Up @@ -1527,19 +1531,19 @@ class Monitor extends BeanModel {
}

/**
* Gets Full Path-Name (Groups and Name)
* @returns {Promise<string>} Full path name of this monitor
* Gets the full path
* @returns {Promise<string[]>} Full path (includes groups and the name) of the monitor
*/
async getPathName() {
let path = this.name;
async getPath() {
const path = [ this.name ];

if (this.parent === null) {
return path;
}

let parent = await Monitor.getParent(this.id);
while (parent !== null) {
path = `${parent.name} / ${path}`;
path.unshift(parent.name);
parent = await Monitor.getParent(parent.id);
}

Expand Down
5 changes: 1 addition & 4 deletions src/pages/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,7 @@ export default {
},

group() {
if (!this.monitor.pathName.includes("/")) {
return "";
}
return this.monitor.pathName.substr(0, this.monitor.pathName.lastIndexOf("/"));
return this.monitor.path.slice(0, -1).join(" / ");
},

pushURL() {
Expand Down
1 change: 1 addition & 0 deletions src/pages/EditMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ message HealthCheckResponse {
// group monitor fields
this.monitor.childrenIDs = undefined;
this.monitor.forceInactive = undefined;
this.monitor.path = undefined;
this.monitor.pathName = undefined;
this.monitor.screenshot = undefined;

Expand Down
Loading