mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-24 23:52:35 +02:00
feat: Adjust default friendly name
This commit is contained in:
parent
5a8e194b94
commit
1019527d8c
2 changed files with 10 additions and 8 deletions
|
@ -64,6 +64,7 @@
|
||||||
"Expected Value": "Expected Value",
|
"Expected Value": "Expected Value",
|
||||||
"Json Query Expression": "Json Query Expression",
|
"Json Query Expression": "Json Query Expression",
|
||||||
"Friendly Name": "Friendly Name",
|
"Friendly Name": "Friendly Name",
|
||||||
|
"defaultFriendlyName": "New Monitor",
|
||||||
"URL": "URL",
|
"URL": "URL",
|
||||||
"Hostname": "Hostname",
|
"Hostname": "Hostname",
|
||||||
"Host URL": "Host URL",
|
"Host URL": "Host URL",
|
||||||
|
|
|
@ -1162,16 +1162,18 @@ export default {
|
||||||
return this.monitor.hostname;
|
return this.monitor.hostname;
|
||||||
}
|
}
|
||||||
if (this.monitor.url) {
|
if (this.monitor.url) {
|
||||||
try {
|
if (this.monitor.url !== "http://" && this.monitor.url !== "https://") {
|
||||||
const url = new URL(this.monitor.url);
|
// Ensure monitor without a URL is not affected by invisible URL.
|
||||||
return url.hostname;
|
try {
|
||||||
} catch (e) {
|
const url = new URL(this.monitor.url);
|
||||||
// Handle invalid URL, maybe return a generic placeholder or empty string
|
return url.hostname;
|
||||||
return this.$t("My Monitor");
|
} catch (e) {
|
||||||
|
return this.monitor.url.replace(/https?:\/\//, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Default placeholder if neither hostname nor URL is available
|
// Default placeholder if neither hostname nor URL is available
|
||||||
return this.$t("My Monitor");
|
return this.$t("defaultFriendlyName");
|
||||||
},
|
},
|
||||||
|
|
||||||
ipRegex() {
|
ipRegex() {
|
||||||
|
@ -1717,7 +1719,6 @@ message HealthCheckResponse {
|
||||||
|
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
|
|
||||||
// Use defaultFriendlyName if Friendly Name is empty
|
|
||||||
if (!this.monitor.name) {
|
if (!this.monitor.name) {
|
||||||
this.monitor.name = this.defaultFriendlyName;
|
this.monitor.name = this.defaultFriendlyName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue