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( .pipe(
withLatestFrom(location$ take(1),
.pipe( map(({ href }) => new URL(base, href)
take(1), .toString()
map(({ href }) => new URL(base, href)) .replace(/\/$/, "")
)
),
map(([location, origin]) => location.href
.replace(origin.href, "")
.split("/")
.slice(1)
.map(() => "..")
.join("/")
) )
) )