File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
vendor/json-stringify-safe Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 4
4
var TraceKit = require ( '../vendor/TraceKit/tracekit' ) ;
5
5
var RavenConfigError = require ( './configError' ) ;
6
6
var utils = require ( './utils' ) ;
7
+ var stringify = require ( '../vendor/json-stringify-safe/stringify' ) ;
7
8
8
9
var isFunction = utils . isFunction ;
9
10
var isUndefined = utils . isUndefined ;
@@ -428,7 +429,7 @@ Raven.prototype = {
428
429
*/
429
430
getContext : function ( ) {
430
431
// lol javascript
431
- return JSON . parse ( JSON . stringify ( this . _globalContext ) ) ;
432
+ return JSON . parse ( stringify ( this . _globalContext ) ) ;
432
433
} ,
433
434
434
435
/*
@@ -1285,7 +1286,7 @@ Raven.prototype = {
1285
1286
// NOTE: auth is intentionally sent as part of query string (NOT as custom
1286
1287
// HTTP header) so as to avoid preflight CORS requests
1287
1288
request . open ( 'POST' , url + '?' + urlencode ( opts . auth ) ) ;
1288
- request . send ( JSON . stringify ( opts . data ) ) ;
1289
+ request . send ( stringify ( opts . data ) ) ;
1289
1290
} ,
1290
1291
1291
1292
// Note: this is shitty, but I can't figure out how to get
Original file line number Diff line number Diff line change
1
+ exports = module . exports = stringify
2
+ exports . getSerialize = serializer
3
+
4
+ function stringify ( obj , replacer , spaces , cycleReplacer ) {
5
+ return JSON . stringify ( obj , serializer ( replacer , cycleReplacer ) , spaces )
6
+ }
7
+
8
+ function serializer ( replacer , cycleReplacer ) {
9
+ var stack = [ ] , keys = [ ]
10
+
11
+ if ( cycleReplacer == null ) cycleReplacer = function ( key , value ) {
12
+ if ( stack [ 0 ] === value ) return "[Circular ~]"
13
+ return "[Circular ~." + keys . slice ( 0 , stack . indexOf ( value ) ) . join ( "." ) + "]"
14
+ }
15
+
16
+ return function ( key , value ) {
17
+ if ( stack . length > 0 ) {
18
+ var thisPos = stack . indexOf ( this )
19
+ ~ thisPos ? stack . splice ( thisPos + 1 ) : stack . push ( this )
20
+ ~ thisPos ? keys . splice ( thisPos , Infinity , key ) : keys . push ( key )
21
+ if ( ~ stack . indexOf ( value ) ) value = cycleReplacer . call ( this , key , value )
22
+ }
23
+ else stack . push ( value )
24
+
25
+ return replacer == null ? value : replacer . call ( this , key , value )
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments