Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/rest-coercion/urlencoded-any.suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ function suite(prefix, ctx) {
// Numbers larger than MAX_SAFE_INTEGER are treated as strings
['arg=2343546576878989879789', '2343546576878989879789'],
['arg=-2343546576878989879789', '-2343546576878989879789'],
// Numbers starting with a leading zero are treated as strings
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', '0668'],
// However, floats are correctly parsed
['arg=0.42', 0.42],
// Scientific notation should be recognized as a number
['arg=1.234e%2B30', '1.234e+30'],
['arg=-1.234e%2B30', '-1.234e+30'],
Expand Down
18 changes: 18 additions & 0 deletions test/rest-coercion/urlencoded-array.suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ function suite(prefix, ctx) {
['arg={}', ERROR_BAD_REQUEST],
['arg={"a":true}', ERROR_BAD_REQUEST],

// Numbers starting with a leading zero are parsed,
// because we know the expected type is a number.
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', [668]],
['arg=0.42', [0.42]],

// Malformed JSON should trigger ERROR_BAD_REQUEST
['arg={malformed}', ERROR_BAD_REQUEST],
['arg=[malformed]', ERROR_BAD_REQUEST],
Expand Down Expand Up @@ -163,6 +169,12 @@ function suite(prefix, ctx) {
['arg={}', ['{}']],
['arg={"a":true}', ['{"a":true}']],
['arg={malformed}', ['{malformed}']],

// Numbers starting with a leading zero are treated as strings
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', ['0668']],
['arg=0.42', ['0.42']],

// Invalid values should trigger ERROR_BAD_REQUEST
['arg=[1]', ERROR_BAD_REQUEST],
['arg=[1,2]', ERROR_BAD_REQUEST],
Expand Down Expand Up @@ -249,6 +261,12 @@ function suite(prefix, ctx) {
// Scientific notation - should it be recognized as a number?
['arg=1.234e%2B30&arg=-1.234e%2B30', ['1.234e+30', '-1.234e+30']],

// Integers starting with a leading zero are treated as strings
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', ['0668']],
// However, floats are correctly parsed
['arg=0.42', [0.42]],

// Valid values - JSON encoding
['arg=[]', []],
['arg=["text",10,false]', ['text', 10, false]],
Expand Down
6 changes: 6 additions & 0 deletions test/rest-coercion/urlencoded-integer.suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ function suite(prefix, ctx) {
['arg=[1,2]', ERROR_BAD_REQUEST],
['arg={}', ERROR_BAD_REQUEST],
['arg={"a":true}', ERROR_BAD_REQUEST],

// Numbers starting with a leading zero are parsed,
// because we know the expected type is a number.
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', 668],
['arg=0.42', ERROR_BAD_REQUEST], // not an integer
]);
});
}
6 changes: 6 additions & 0 deletions test/rest-coercion/urlencoded-number.suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ function suite(prefix, ctx) {
['arg=[1,2]', ERROR_BAD_REQUEST],
['arg={}', ERROR_BAD_REQUEST],
['arg={"a":true}', ERROR_BAD_REQUEST],

// Numbers starting with a leading zero are parsed,
// because we know the expected type is a number.
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', 668],
['arg=0.42', 0.42],
]);
});
}
5 changes: 5 additions & 0 deletions test/rest-coercion/urlencoded-string.suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ function suite(prefix, ctx) {
// Scientific notation
['arg=1.234e%2B30', '1.234e+30'],
['arg=-1.234e%2B30', '-1.234e+30'],

// Numbers starting with a leading zero are treated as strings
// See https://github.com/strongloop/strong-remoting/issues/143
['arg=0668', '0668'],
['arg=0.42', '0.42'],
]);
});
}