mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2025-02-21 20:29:55 +01:00
Improved readability of URL for search sharing
This commit is contained in:
parent
db74632076
commit
ee1496499a
@ -86,8 +86,15 @@ export function watchSearchShare(
|
|||||||
map(({ value }) => {
|
map(({ value }) => {
|
||||||
const url = getLocation()
|
const url = getLocation()
|
||||||
url.hash = ""
|
url.hash = ""
|
||||||
url.searchParams.delete("h")
|
|
||||||
url.searchParams.set("q", value)
|
/* Compute readable query strings */
|
||||||
|
value = value
|
||||||
|
.replace(/\s+/g, "+") /* Collapse whitespace */
|
||||||
|
.replace(/&/g, "%26") /* Escape '&' character */
|
||||||
|
.replace(/=/g, "%3D") /* Escape '=' character */
|
||||||
|
|
||||||
|
/* Replace query string */
|
||||||
|
url.search = `q=${value}`
|
||||||
return { url }
|
return { url }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user