mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-24 15:52:33 +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",
|
||||
"Json Query Expression": "Json Query Expression",
|
||||
"Friendly Name": "Friendly Name",
|
||||
"defaultFriendlyName": "New Monitor",
|
||||
"URL": "URL",
|
||||
"Hostname": "Hostname",
|
||||
"Host URL": "Host URL",
|
||||
|
|
|
@ -1162,16 +1162,18 @@ export default {
|
|||
return this.monitor.hostname;
|
||||
}
|
||||
if (this.monitor.url) {
|
||||
try {
|
||||
const url = new URL(this.monitor.url);
|
||||
return url.hostname;
|
||||
} catch (e) {
|
||||
// Handle invalid URL, maybe return a generic placeholder or empty string
|
||||
return this.$t("My Monitor");
|
||||
if (this.monitor.url !== "http://" && this.monitor.url !== "https://") {
|
||||
// Ensure monitor without a URL is not affected by invisible URL.
|
||||
try {
|
||||
const url = new URL(this.monitor.url);
|
||||
return url.hostname;
|
||||
} catch (e) {
|
||||
return this.monitor.url.replace(/https?:\/\//, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default placeholder if neither hostname nor URL is available
|
||||
return this.$t("My Monitor");
|
||||
return this.$t("defaultFriendlyName");
|
||||
},
|
||||
|
||||
ipRegex() {
|
||||
|
@ -1717,7 +1719,6 @@ message HealthCheckResponse {
|
|||
|
||||
this.processing = true;
|
||||
|
||||
// Use defaultFriendlyName if Friendly Name is empty
|
||||
if (!this.monitor.name) {
|
||||
this.monitor.name = this.defaultFriendlyName;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue