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:
parent
db74632076
commit
ee1496499a
@ -86,8 +86,15 @@ export function watchSearchShare(
|
||||
map(({ value }) => {
|
||||
const url = getLocation()
|
||||
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 }
|
||||
})
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user