From eb6f3aed5affcf340f0eee01bc8ef6a118b4f7e7 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Sat, 6 Apr 2019 12:37:33 -0700 Subject: Couple URL helpers to global window Make dat monad put in work for me. --- src/lib/url.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/url.js b/src/lib/url.js index b3ef40c..83a8d12 100644 --- a/src/lib/url.js +++ b/src/lib/url.js @@ -1,8 +1,9 @@ -import { location, history } from 'browser-monads' -export const parseQuery = ({ search } = location) => - search && parseQueryString(search) +import { window } from 'browser-monads' -const parseQueryString = query => +export const parseQuery = () => + window.location.search && parseQueryString(window.location.search) + +export const parseQueryString = query => query .split('?')[1] .split('&') @@ -20,6 +21,6 @@ export const objectToQuery = query => '?' ) -export const writeQuery = (queryObj, { pushState } = history) => { - pushState({}, '', objectToQuery(queryObj)) +export const writeQuery = queryObj => { + window.history.pushState({}, '', objectToQuery(queryObj)) } -- cgit v1.2.3