mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
chore(URL.ts): update toString method to conditionally add route and improve URL construction logic
chore(MonitorStep.ts): remove redundant default monitor assignments in getDefaultMonitorStep method chore(Port.ts): change toJSON method to return port value as a number instead of string
This commit is contained in:
@@ -98,16 +98,20 @@ export default class URL extends DatabaseProperty {
|
||||
public override toString(): string {
|
||||
let urlString: string = `${this.protocol}${this.hostname || this.email}`;
|
||||
if (!this.email && !urlString.startsWith("mailto:")) {
|
||||
if (this.route && this.route.toString().startsWith("/")) {
|
||||
if (urlString.endsWith("/")) {
|
||||
urlString = urlString.substring(0, urlString.length - 1);
|
||||
// Only add route if it's not empty
|
||||
const routeString: string = this.route ? this.route.toString() : "";
|
||||
if (routeString) {
|
||||
if (routeString.startsWith("/")) {
|
||||
if (urlString.endsWith("/")) {
|
||||
urlString = urlString.substring(0, urlString.length - 1);
|
||||
}
|
||||
urlString += routeString;
|
||||
} else {
|
||||
if (urlString.endsWith("/")) {
|
||||
urlString = urlString.substring(0, urlString.length - 1);
|
||||
}
|
||||
urlString += "/" + routeString;
|
||||
}
|
||||
urlString += this.route.toString();
|
||||
} else {
|
||||
if (urlString.endsWith("/")) {
|
||||
urlString = urlString.substring(0, urlString.length - 1);
|
||||
}
|
||||
urlString += "/" + this.route.toString();
|
||||
}
|
||||
|
||||
if (Object.keys(this.params).length > 0) {
|
||||
|
||||
@@ -448,24 +448,6 @@ export default class MonitorStep extends DatabaseProperty {
|
||||
: undefined,
|
||||
}) as any;
|
||||
|
||||
if (monitorStep.data && !monitorStep.data?.logMonitor) {
|
||||
monitorStep.data.logMonitor = MonitorStepLogMonitorUtil.getDefault();
|
||||
}
|
||||
|
||||
if (monitorStep.data && !monitorStep.data?.traceMonitor) {
|
||||
monitorStep.data.traceMonitor = MonitorStepTraceMonitorUtil.getDefault();
|
||||
}
|
||||
|
||||
if (monitorStep.data && !monitorStep.data?.metricMonitor) {
|
||||
monitorStep.data.metricMonitor =
|
||||
MonitorStepMetricMonitorUtil.getDefault();
|
||||
}
|
||||
|
||||
if (monitorStep.data && !monitorStep.data?.exceptionMonitor) {
|
||||
monitorStep.data.exceptionMonitor =
|
||||
MonitorStepExceptionMonitorUtil.getDefault();
|
||||
}
|
||||
|
||||
return monitorStep;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export default class Port extends DatabaseProperty {
|
||||
public override toJSON(): JSONObject {
|
||||
return {
|
||||
_type: ObjectType.Port,
|
||||
value: (this as Port).toString(),
|
||||
value: (this as Port).toNumber(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user