MCPcopy
hub / github.com/gitalk/gitalk / queryParse

Function queryParse

src/util.js:3–16  ·  view source on GitHub ↗
(search = window.location.search)

Source from the content-addressed store, hash-verified

1import axios from 'axios'
2
3export const queryParse = (search = window.location.search) => {
4 if (!search) return {}
5 const queryString = search[0] === '?' ? search.substring(1) : search
6 const query = {}
7 queryString
8 .split('&')
9 .forEach(queryStr => {
10 const [key, value] = queryStr.split('=')
11 /* istanbul ignore else */
12 if (key) query[decodeURIComponent(key)] = decodeURIComponent(value)
13 })
14
15 return query
16}
17
18export const queryStringify = query => {
19 const queryString = Object.keys(query)

Callers 2

constructorMethod · 0.90
util.test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected