Fixed wrong URLs in search when instant loading is enabled

This commit is contained in:
squidfunk 2020-02-29 11:30:37 +01:00
parent c98e2d39c7
commit 8556912bb4

View File

@ -79,21 +79,13 @@ export function setupSearchWorker(
): WorkerHandler<SearchMessage> { ): WorkerHandler<SearchMessage> {
const worker = new Worker(url) const worker = new Worker(url)
/* Compute new base URL when location changes */ /* Ensure stable base URL */
const origin$ = location$ const origin$ = location$
.pipe(
withLatestFrom(location$
.pipe( .pipe(
take(1), take(1),
map(({ href }) => new URL(base, href)) map(({ href }) => new URL(base, href)
) .toString()
), .replace(/\/$/, "")
map(([location, origin]) => location.href
.replace(origin.href, "")
.split("/")
.slice(1)
.map(() => "..")
.join("/")
) )
) )