| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,9 +91,7 @@ exports.parse = function(str){ | |||
| 91 | 91 | var stringify = exports.stringify = function(obj, prefix) { | |
| 92 | 92 | var ret = []; | |
| 93 | 93 | if (Array.isArray(obj)) { | |
| 94 | - if (typeof prefix === 'undefined' ) { | ||
| 95 | - throw new Error("Value must be a hash"); | ||
| 96 | - } | ||
| 94 | + if (!prefix) throw new TypeError('stringify expects an object'); | ||
| 97 | 95 | for (var i = 0; i < obj.length; i++) { | |
| 98 | 96 | ret.push( stringify(obj[i], prefix + '[]') ); | |
| 99 | 97 | } | |
@@ -109,9 +107,7 @@ var stringify = exports.stringify = function(obj, prefix) { | |||
| 109 | 107 | } | |
| 110 | 108 | return ret.join("&"); | |
| 111 | 109 | } else if ('string' == typeof obj) { | |
| 112 | - if (typeof prefix === 'undefined') { | ||
| 113 | - throw new Error("Value must be a hash"); | ||
| 114 | - } | ||
| 110 | + if (!prefix) throw new TypeError('stringify expects an object'); | ||
| 115 | 111 | return prefix + '=' + encodeURIComponent(obj); | |
| 116 | 112 | } else { | |
| 117 | 113 | return prefix; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,8 +44,8 @@ var qs = require('../') | |||
| 44 | 44 | {query_string: 'user[name][first]=tj&user[name][last]=holowaychuk', parsed: { user: { name: { first: 'tj', last: 'holowaychuk' }}}} | |
| 45 | 45 | ], | |
| 46 | 46 | 'errors': [ | |
| 47 | - {parsed: 'foo=bar', message: 'Value must be a hash'}, | ||
| 48 | - {parsed: ['foo','bar'], message: 'Value must be a hash'} | ||
| 47 | + { parsed: 'foo=bar', message: 'stringify expects an object' }, | ||
| 48 | + { parsed: ['foo', 'bar'], message: 'stringify expects an object' } | ||
| 49 | 49 | ] | |
| 50 | 50 | }; | |
| 51 | 51 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments