Skip to content

Build your personal knowledge base with Trilium Notes

style(client): wrap the same-document URL comparison

matt wilkie48dea149fdd5
diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts
index 17cea56ff1..7a3e6368f3 100644
--- a/apps/client/src/services/link.ts
+++ b/apps/client/src/services/link.ts
@@ -439,11 +439,12 @@ export function parseNavigationStateFromUrl(
};
}
-/** Whether `url` addresses the document at `location`, including its query string, ignoring the hash. */
+/** Whether `url` addresses the document at `location`, query string included, hash ignored. */
function isSameDocumentUrl(url: string, hashIdx: number, location: UrlParts) {
const documentUrl = url.slice(0, hashIdx);
- return documentUrl === `${location.protocol}//${location.host}${location.pathname}${location.search}`;
+ const { protocol, host, pathname, search } = location;
+ return documentUrl === `${protocol}//${host}${pathname}${search}`;
}
/** Iterates the `name=value` pairs of a hash's parameter string, decoding both sides. */