mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-12-01 02:27:17 +01:00
Fixed wrong URLs in search when instant loading is enabled
This commit is contained in:
parent
c98e2d39c7
commit
8556912bb4
@ -79,21 +79,13 @@ export function setupSearchWorker(
|
||||
): WorkerHandler<SearchMessage> {
|
||||
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(/\/$/, "")
|
||||
)
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user