* Parse the given x-www-form-urlencoded `str`. * * @param {String} str * @return {Object} * @api private
(string_)
| 140 | */ |
| 141 | |
| 142 | function 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. |
nothing calls this directly
no outgoing calls
no test coverage detected