MCPcopy Create free account
hub / github.com/forwardemail/superagent / parseString

Function parseString

src/client.js:142–161  ·  view source on GitHub ↗

* Parse the given x-www-form-urlencoded `str`. * * @param {String} str * @return {Object} * @api private

(string_)

Source from the content-addressed store, hash-verified

140 */
141
142function parseString(string_) {
143 const object = {};
144 const pairs = string_.split('&');
145 let pair;
146 let pos;
147
148 for (let i = 0, length_ = pairs.length; i < length_; ++i) {
149 pair = pairs[i];
150 pos = pair.indexOf('=');
151 if (pos === -1) {
152 object[decodeURIComponent(pair)] = '';
153 } else {
154 object[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(
155 pair.slice(pos + 1)
156 );
157 }
158 }
159
160 return object;
161}
162
163/**
164 * Expose parser.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected