mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved readability of URL for search sharing
This commit is contained in:
@@ -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 }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user