mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix(URL): streamline route handling in toString method
This commit is contained in:
@@ -98,20 +98,16 @@ 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:")) {
|
||||
// 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;
|
||||
if (this.route && this.route.toString().startsWith("/")) {
|
||||
if (urlString.endsWith("/")) {
|
||||
urlString = urlString.substring(0, urlString.length - 1);
|
||||
}
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user