Comparing version 2.3.0 to 2.3.1
@@ -64,2 +64,4 @@ import { getDeepObject } from './object-util.js'; | ||
let arrayRepeatBracketIndex = -1; | ||
let prevIndex = -1; | ||
let prevChar = -1; | ||
// Have a boundary of input.length + 1 to access last pair inside the loop. | ||
@@ -99,3 +101,8 @@ for (let i = 0; i < inputLength + 1; i++) { | ||
if (currentValue === undefined) { | ||
currentObj[currentKey] = newValue; | ||
if (arrayRepeatBracketIndex > -1) { | ||
currentObj[currentKey] = [newValue]; | ||
} | ||
else { | ||
currentObj[currentKey] = newValue; | ||
} | ||
} | ||
@@ -132,4 +139,3 @@ // Optimization: value.pop is faster than Array.isArray(value) | ||
if (arrayRepeat && arrayRepeatSyntax === 'bracket') { | ||
const prevIndex = i - 1; | ||
if (input.charCodeAt(prevIndex) === 91) { | ||
if (prevChar === 91) { | ||
arrayRepeatBracketIndex = prevIndex; | ||
@@ -141,11 +147,13 @@ } | ||
equalityIndex <= startingIndex) { | ||
keyChunk = computeKeySlice(input, keySeparatorIndex + 1, i, keyHasPlus, shouldDecodeKey); | ||
currentKey = keyDeserializer(keyChunk); | ||
if (lastKey !== undefined) { | ||
currentObj = getDeepObject(currentObj, lastKey, currentKey, undefined, isJsNestingSyntax); | ||
if (keySeparatorIndex !== prevIndex) { | ||
keyChunk = computeKeySlice(input, keySeparatorIndex + 1, i, keyHasPlus, shouldDecodeKey); | ||
currentKey = keyDeserializer(keyChunk); | ||
if (lastKey !== undefined) { | ||
currentObj = getDeepObject(currentObj, lastKey, currentKey, undefined, isJsNestingSyntax); | ||
} | ||
lastKey = currentKey; | ||
keyHasPlus = false; | ||
shouldDecodeKey = false; | ||
} | ||
lastKey = currentKey; | ||
keySeparatorIndex = i; | ||
keyHasPlus = false; | ||
shouldDecodeKey = false; | ||
keyIsIndex = true; | ||
@@ -160,3 +168,3 @@ keyIsDot = false; | ||
equalityIndex <= startingIndex) { | ||
if (keySeparatorIndex !== i - 1) { | ||
if (keySeparatorIndex !== prevIndex) { | ||
keyChunk = computeKeySlice(input, keySeparatorIndex + 1, i, keyHasPlus, shouldDecodeKey); | ||
@@ -181,3 +189,3 @@ currentKey = keyDeserializer(keyChunk); | ||
equalityIndex <= startingIndex) { | ||
if (keySeparatorIndex !== i - 1) { | ||
if (keySeparatorIndex !== prevIndex) { | ||
keyChunk = computeKeySlice(input, keySeparatorIndex + 1, i, keyHasPlus, shouldDecodeKey); | ||
@@ -225,4 +233,6 @@ currentKey = keyDeserializer(keyChunk); | ||
} | ||
prevIndex = i; | ||
prevChar = c; | ||
} | ||
return result; | ||
} |
{ | ||
"name": "picoquery", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "A small library for parsing and serialisation query strings", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
31592
489