\begin{quote}
Parse and stringify URL \href{http://en.wikipedia.org/wiki/Query_string}{\texttt{ query strings}} \end{quote}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23724}{}\doxysection{$<$/blockquote$>$}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23724}
{\bfseries{🔥 Want to strengthen your core Java\+Script skills and master ES6?}}~\newline
I would personally recommend this awesome \href{https://ES6.io/friend/AWESOME}{\texttt{ ES6 course}} by Wes Bos. You might also like his \href{https://ReactForBeginners.com/friend/AWESOME}{\texttt{ React course}}.

\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23726}{}\doxysection{Install}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23726}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install -\/-\/save query-\/string }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23727}{}\doxysection{Usage}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23727}

\begin{DoxyCode}{0}
\DoxyCodeLine{const queryString = require('query-\/string');}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(location.search);}
\DoxyCodeLine{//=> '?foo=bar'}
\DoxyCodeLine{}
\DoxyCodeLine{const parsed = queryString.parse(location.search);}
\DoxyCodeLine{console.log(parsed);}
\DoxyCodeLine{//=> \{foo: 'bar'\}}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(location.hash);}
\DoxyCodeLine{//=> '\#token=bada55cafe'}
\DoxyCodeLine{}
\DoxyCodeLine{const parsedHash = queryString.parse(location.hash);}
\DoxyCodeLine{console.log(parsedHash);}
\DoxyCodeLine{//=> \{token: 'bada55cafe'\}}
\DoxyCodeLine{}
\DoxyCodeLine{parsed.foo = 'unicorn';}
\DoxyCodeLine{parsed.ilike = 'pizza';}
\DoxyCodeLine{}
\DoxyCodeLine{const stringified = queryString.stringify(parsed);}
\DoxyCodeLine{//=> 'foo=unicorn\&ilike=pizza'}
\DoxyCodeLine{}
\DoxyCodeLine{location.search = stringified;}
\DoxyCodeLine{// note that `location.search` automatically prepends a question mark}
\DoxyCodeLine{console.log(location.search);}
\DoxyCodeLine{//=> '?foo=unicorn\&ilike=pizza' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23728}{}\doxysection{API}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23728}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23729}{}\doxysubsection{.\+parse($<$em$>$string$<$/em$>$, $<$em$>$\mbox{[}options\mbox{]}$<$/em$>$)}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23729}
Parse a query string into an object. Leading {\ttfamily ?} or {\ttfamily \#} are ignored, so you can pass {\ttfamily location.\+search} or {\ttfamily location.\+hash} directly.

The returned object is created with \href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create}{\texttt{ {\ttfamily Object.\+create(null)}}} and thus does not have a {\ttfamily prototype}.\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23730}{}\doxysubsubsection{array\+Format}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23730}
Type\+: {\ttfamily string}~\newline
 Default\+: `\textquotesingle{}none'\`{}

Supports both {\ttfamily index} for an indexed array representation or {\ttfamily bracket} for a {\itshape bracketed} array representation.


\begin{DoxyItemize}
\item {\ttfamily bracket}\+: stands for parsing correctly arrays with bracket representation on the query string, such as\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.parse('foo[]=1\&foo[]=2\&foo[]=3', \{arrayFormat: 'bracket'\});}
\DoxyCodeLine{//=> foo: [1,2,3] }

\end{DoxyCode}



\begin{DoxyItemize}
\item {\ttfamily index}\+: stands for parsing taking the index into account, such as\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.parse('foo[0]=1\&foo[1]=2\&foo[3]=3', \{arrayFormat: 'index'\});}
\DoxyCodeLine{//=> foo: [1,2,3] }

\end{DoxyCode}



\begin{DoxyItemize}
\item {\ttfamily none}\+: is the {\bfseries{default}} option and removes any bracket representation, such as\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.parse('foo=1\&foo=2\&foo=3');}
\DoxyCodeLine{//=> foo: [1,2,3] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23731}{}\doxysubsection{.\+stringify($<$em$>$object$<$/em$>$, $<$em$>$\mbox{[}options\mbox{]}$<$/em$>$)}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23731}
Stringify an object into a query string, sorting the keys.\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23732}{}\doxysubsubsection{strict}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23732}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Strictly encode URI components with \href{https://github.com/kevva/strict-uri-encode}{\texttt{ strict-\/uri-\/encode}}. It uses \href{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent}{\texttt{ encode\+URIComponent}} if set to false. You probably \href{https://github.com/sindresorhus/query-string/issues/42}{\texttt{ don\textquotesingle{}t care}} about this option.\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23733}{}\doxysubsubsection{encode}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23733}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

\href{https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent}{\texttt{ URL encode}} the keys and values.\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23734}{}\doxysubsubsection{array\+Format}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23734}
Type\+: {\ttfamily string}~\newline
 Default\+: `\textquotesingle{}none'\`{}

Supports both {\ttfamily index} for an indexed array representation or {\ttfamily bracket} for a {\itshape bracketed} array representation.


\begin{DoxyItemize}
\item {\ttfamily bracket}\+: stands for parsing correctly arrays with bracket representation on the query string, such as\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.stringify(\{foo: [1,2,3]\}, \{arrayFormat: 'bracket'\});}
\DoxyCodeLine{// => foo[]=1\&foo[]=2\&foo[]=3 }

\end{DoxyCode}



\begin{DoxyItemize}
\item {\ttfamily index}\+: stands for parsing taking the index into account, such as\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.stringify(\{foo: [1,2,3]\}, \{arrayFormat: 'index'\});}
\DoxyCodeLine{// => foo[0]=1\&foo[1]=2\&foo[3]=3 }

\end{DoxyCode}



\begin{DoxyItemize}
\item {\ttfamily none}\+: is the {\bfseries{default}} option and removes any bracket representation, such as\+:
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.stringify(\{foo: [1,2,3]\});}
\DoxyCodeLine{// => foo=1\&foo=2\&foo=3 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23735}{}\doxysubsection{.\+extract($<$em$>$string$<$/em$>$)}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23735}
Extract a query string from a URL that can be passed into {\ttfamily .parse()}.\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23736}{}\doxysection{Nesting}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23736}
This module intentionally doesn\textquotesingle{}t support nesting as it\textquotesingle{}s not spec\textquotesingle{}d and varies between implementations, which causes a lot of \href{https://github.com/visionmedia/node-querystring/issues}{\texttt{ edge cases}}.

You\textquotesingle{}re much better off just converting the object to a JSON string\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.stringify(\{}
\DoxyCodeLine{    foo: 'bar',}
\DoxyCodeLine{    nested: JSON.stringify(\{}
\DoxyCodeLine{        unicorn: 'cake'}
\DoxyCodeLine{    \})}
\DoxyCodeLine{\});}
\DoxyCodeLine{//=> 'foo=bar\&nested=\%7B\%22unicorn\%22\%3A\%22cake\%22\%7D' }

\end{DoxyCode}


However, there is support for multiple instances of the same key\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.parse('likes=cake\&name=bob\&likes=icecream');}
\DoxyCodeLine{//=> \{likes: ['cake', 'icecream'], name: 'bob'\}}
\DoxyCodeLine{}
\DoxyCodeLine{queryString.stringify(\{color: ['taupe', 'chartreuse'], id: '515'\});}
\DoxyCodeLine{//=> 'color=chartreuse\&color=taupe\&id=515' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23737}{}\doxysection{Falsy values}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23737}
Sometimes you want to unset a key, or maybe just make it present without assigning a value to it. Here is how falsy values are stringified\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{queryString.stringify(\{foo: false\});}
\DoxyCodeLine{//=> 'foo=false'}
\DoxyCodeLine{}
\DoxyCodeLine{queryString.stringify(\{foo: null\});}
\DoxyCodeLine{//=> 'foo'}
\DoxyCodeLine{}
\DoxyCodeLine{queryString.stringify(\{foo: undefined\});}
\DoxyCodeLine{//=> '' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_query_string_readme_autotoc_md23738}{}\doxysection{License}\label{md_sfcode_node_modules_query_string_readme_autotoc_md23738}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 