Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

buildUrl uses JSON.stringify instead of toJSON method if it exists #6128

Closed
pdanpdan opened this issue Feb 5, 2014 · 2 comments
Closed

buildUrl uses JSON.stringify instead of toJSON method if it exists #6128

pdanpdan opened this issue Feb 5, 2014 · 2 comments

Comments

@pdanpdan
Copy link

pdanpdan commented Feb 5, 2014

buildUrl uses JSON.stringify to convert objects to string for $http.get,
but this converts Date objects to a quote enclosed string:
JSON.stringify(new Date()) => ""2014-02-05T15:15:22.612Z""
(new Date()).toJSON() => "2014-02-05T15:40:48.080Z"
I think buildUrl should use the object's toJSON method if it exists
This also applies to other objects that provide toJSON methods

@circlingthesun
Copy link

Currently (1.3.0-build.2753+sha.f37a2da) buildUrl users angular.toJSON(). Dates however still get quoted and one ends up with URL's that look like http://localhost:6543/api/booking?from=%222014-05-23T00:46:00.710Z%22&staff_id=1&until=%222014-05-29T21:59:59.710Z%22"

@danbarua
Copy link
Contributor

Duplicated at #8150

danbarua added a commit to danbarua/angular.js that referenced this issue Jul 11, 2014
$http was wrapping dates in double quotes leading to query strings like this:
  ?date=%222014-07-07T23:00:00.000Z%22
Instead of calling JSON.stringify, this fix checks to see if a param object
has a toJSON() function and uses that for encoding, falling back to
JSON.stringify as per the previous behaviour.

Closes angular#8150 and angular#6128
danbarua added a commit to danbarua/angular.js that referenced this issue Jul 11, 2014
$http was wrapping dates in double quotes leading to query strings like this:
  ?date=%222014-07-07T23:00:00.000Z%22
Instead of calling JSON.stringify, this fix checks to see if a param object
has a toJSON() function and uses that for encoding, falling back to
JSON.stringify as per the previous behaviour.

Closes angular#8150 and angular#6128
IgorMinar pushed a commit that referenced this issue Jul 16, 2014
This commit special cases date handling rather than calling toJSON as we always need
a string representation of the object.

$http was wrapping dates in double quotes leading to query strings like this:
  ?date=%222014-07-07T23:00:00.000Z%22

Closes #8150
Closes #6128
Closes #8154
ckknight pushed a commit to ckknight/angular.js that referenced this issue Jul 16, 2014
This commit special cases date handling rather than calling toJSON as we always need
a string representation of the object.

$http was wrapping dates in double quotes leading to query strings like this:
  ?date=%222014-07-07T23:00:00.000Z%22

Closes angular#8150
Closes angular#6128
Closes angular#8154
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants