Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'alpinejs/packages/history/src/url.js')
-rw-r--r--alpinejs/packages/history/src/url.js36
1 files changed, 0 insertions, 36 deletions
diff --git a/alpinejs/packages/history/src/url.js b/alpinejs/packages/history/src/url.js
deleted file mode 100644
index 7e2b4b6..0000000
--- a/alpinejs/packages/history/src/url.js
+++ /dev/null
@@ -1,36 +0,0 @@
-
-export function hasQueryParam(param) {
- let queryParams = new URLSearchParams(window.location.search);
-
- return queryParams.has(param)
-}
-
-export function getQueryParam(param) {
- let queryParams = new URLSearchParams(window.location.search);
-
- return queryParams.get(param)
-}
-
-export function setQueryParam(param, value) {
- let queryParams = new URLSearchParams(window.location.search);
-
- queryParams.set(param, value)
-
- let url = urlFromQueryParams(queryParams)
-
- history.replaceState(history.state, '', url)
-}
-
-function urlFromParams(params = {}) {
- let queryParams = new URLSearchParams(window.location.search);
-
- Object.entries(params).forEach(([key, value]) => {
- queryParams.set(key, value)
- })
-
- let queryString = Array.from(queryParams.entries()).length > 0
- ? '?'+params.toString()
- : ''
-
- return window.location.origin + window.location.pathname + '?'+queryString + window.location.hash
-}