Skip to content

Commit 511d6a2

Browse files
author
isaacs
committed
Some more traces of merge collisions. Corrected.
1 parent e8ecb0f commit 511d6a2

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

querystring-parse.js

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ exports.parse = querystring_parse;
4242
* @for querystring
4343
* @static
4444
*/
45-
<<<<<<< HEAD
4645
function querystring_parse (qs, sep, eq, unesc) {
4746
return qs.split(sep || "&")
4847
.map(pieceParser(eq || "=", unesc || unescape))
@@ -51,22 +50,6 @@ function querystring_parse (qs, sep, eq, unesc) {
5150

5251
function unescape (s) {
5352
return decodeURIComponent(s.replace(/\+/g, ' '));
54-
=======
55-
var parse = function (qs, sep, eq) {
56-
// wouldn't Array(qs.split()).map(pieceParser(eq)).reduce(mergeParams) be prettier?
57-
return util.reduce(
58-
util.map(
59-
qs.split(sep || "&"),
60-
pieceParser(eq || "=")
61-
),
62-
{},
63-
mergeParams
64-
);
65-
};
66-
67-
var unescape = function (s) {
68-
return decodeURIComponent(s.replace(/\+/g, ' '));
69-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
7053
};
7154

7255

@@ -79,40 +62,23 @@ var unescape = function (s) {
7962
// return parse(foo[bar], [{bla:"baz"}])
8063
// return parse(foo, {bar:[{bla:"baz"}]})
8164
// return {foo:{bar:[{bla:"baz"}]}}
82-
<<<<<<< HEAD
8365
function pieceParser (eq, unesc) {
8466
return function parsePiece (key, val) {
85-
86-
=======
87-
var pieceParser = function (eq) {
88-
return function parsePiece (key, val) {
89-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
9067
if (arguments.length !== 2) {
9168
// key=val, called from the map/reduce
9269
key = key.split(eq);
9370
return parsePiece(
94-
<<<<<<< HEAD
9571
unesc(key.shift()),
9672
unesc(key.join(eq))
9773
);
98-
=======
99-
unescape(key.shift()),
100-
unescape(key.join(eq))
101-
);
102-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
10374
}
10475
key = key.replace(/^\s+|\s+$/g, '');
10576
if (util.isString(val)) {
10677
val = val.replace(/^\s+|\s+$/g, '');
10778
// convert numerals to numbers
10879
if (!isNaN(val)) {
109-
<<<<<<< HEAD
11080
var numVal = +val;
11181
if (val === numVal.toString(10)) val = numVal;
112-
=======
113-
var numVal = +val;
114-
if (val === numVal.toString(10)) val = numVal;
115-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
11682
}
11783
}
11884
var sliced = /(.*)\[([^\]]*)\]$/.exec(key);
@@ -122,12 +88,8 @@ var pieceParser = function (eq) {
12288
return ret;
12389
}
12490
// ["foo[][bar][][baz]", "foo[][bar][]", "baz"]
125-
<<<<<<< HEAD
12691
var tail = sliced[2],
12792
head = sliced[1];
128-
=======
129-
var tail = sliced[2], head = sliced[1];
130-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
13193

13294
// array: key[]=val
13395
if (!tail) return parsePiece(head, [val]);
@@ -141,7 +103,6 @@ var pieceParser = function (eq) {
141103

142104
// the reducer function that merges each query piece together into one set of params
143105
function mergeParams (params, addition) {
144-
<<<<<<< HEAD
145106
var ret;
146107

147108
if (!params){
@@ -158,39 +119,14 @@ function mergeParams (params, addition) {
158119
ret = mergeObjects(params, addition);
159120
}
160121
return ret;
161-
=======
162-
var ret;
163-
164-
if (!params){
165-
// if it's uncontested, then just return the addition.
166-
ret = addition;
167-
} else if (util.isArray(params)) {
168-
// if the existing value is an array, then concat it.
169-
ret = params.concat(addition);
170-
} else if (!util.isObject(params) || !util.isObject(addition)) {
171-
// if the existing value is not an array, and either are not objects, arrayify it.
172-
ret = [params].concat(addition);
173-
} else {
174-
// else merge them as objects, which is a little more complex
175-
ret = mergeObjects(params, addition);
176-
}
177-
return ret;
178-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
179122
};
180123

181124

182125
// Merge two *objects* together. If this is called, we've already ruled
183126
// out the simple cases, and need to do the for-in business.
184127
function mergeObjects (params, addition) {
185-
<<<<<<< HEAD
186128
for (var i in addition) if (i && addition.hasOwnProperty(i)) {
187129
params[i] = mergeParams(params[i], addition[i]);
188-
=======
189-
for (var i in addition) {
190-
if (i && addition.hasOwnProperty(i)) {
191-
params[i] = mergeParams(params[i], addition[i]);
192-
}
193-
>>>>>>> dfaf3130e7ad0c25f7464dc46bb862c9f0bfb9ee
194130
}
195131
return params;
196132
};

0 commit comments

Comments
 (0)