From 8556912bb4f070efbe3eed7fdcb613c1d4a0c9e6 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 29 Feb 2020 11:30:37 +0100 Subject: [PATCH] Fixed wrong URLs in search when instant loading is enabled --- .../javascripts/workers/search/_/index.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/assets/javascripts/workers/search/_/index.ts b/src/assets/javascripts/workers/search/_/index.ts index 683846a00..caeaa9415 100644 --- a/src/assets/javascripts/workers/search/_/index.ts +++ b/src/assets/javascripts/workers/search/_/index.ts @@ -79,21 +79,13 @@ export function setupSearchWorker( ): WorkerHandler { const worker = new Worker(url) - /* Compute new base URL when location changes */ + /* Ensure stable base URL */ const origin$ = location$ .pipe( - withLatestFrom(location$ - .pipe( - take(1), - map(({ href }) => new URL(base, href)) - ) - ), - map(([location, origin]) => location.href - .replace(origin.href, "") - .split("/") - .slice(1) - .map(() => "..") - .join("/") + take(1), + map(({ href }) => new URL(base, href) + .toString() + .replace(/\/$/, "") ) )