Prevent undesired Date parsing
Native Date parsing is unpredictable and will occasionally turn a string like "/foo/1" into a valid date of Jan 1, 2001. This can be prevented by not parsing a string that begins with a slash. It's likely that this is a rare case, but it's annoying when it does come up.
This commit is contained in:
parent
91851e2025
commit
391e7f43f5
2 changed files with 5 additions and 1 deletions
|
|
@ -20,6 +20,10 @@ o.spec("parseQueryString", function() {
|
|||
var data = parseQueryString("?%3B%3A%40%26%3D%2B%24%2C%2F%3F%25%23=%3B%3A%40%26%3D%2B%24%2C%2F%3F%25%23")
|
||||
o(data).deepEquals({";:@&=+$,/?%#": ";:@&=+$,/?%#"})
|
||||
})
|
||||
o("handles escaped slashes followed by a number", function () {
|
||||
var data = parseQueryString("?hello=%2Fen%2F1")
|
||||
o(data.hello).equals("/en/1")
|
||||
})
|
||||
o("handles escaped square brackets", function() {
|
||||
var data = parseQueryString("?a%5B%5D=b")
|
||||
o(data).deepEquals({"a": ["b"]})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue