From 9c1ed659e9f62db1c0391c9dcd59783087bc14db Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Fri, 23 Jan 2026 09:24:03 +0000 Subject: [PATCH] fix(URL): streamline route handling in toString method --- Common/Types/API/URL.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Common/Types/API/URL.ts b/Common/Types/API/URL.ts index 6725ca4ae1..6071e5a9fd 100644 --- a/Common/Types/API/URL.ts +++ b/Common/Types/API/URL.ts @@ -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) {