fix(URL): streamline route handling in toString method

This commit is contained in:
Nawaz Dhandala
2026-01-23 09:24:03 +00:00
parent 21b761ddbf
commit 9c1ed659e9

View File

@@ -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) {