From 3e12bfe27aa8c96387b2da426189526ef178b574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 27 Jun 2017 11:53:22 +0200 Subject: [PATCH] Going green: support special numeric values for json responses --- lib/cartodb/server.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/cartodb/server.js b/lib/cartodb/server.js index 13d64804..deb88e16 100644 --- a/lib/cartodb/server.js +++ b/lib/cartodb/server.js @@ -310,6 +310,25 @@ function bootstrap(opts) { app.enable('jsonp callback'); app.disable('x-powered-by'); app.disable('etag'); + + // Fix: https://github.com/CartoDB/Windshaft-cartodb/issues/705 + // See: http://expressjs.com/en/4x/api.html#app.set + app.set('json replacer', function (key, value) { + if (value !== value) { + return 'NaN'; + } + + if (value === Infinity) { + return 'Infinity'; + } + + if (value === -Infinity) { + return '-Infinity'; + } + + return value; + }); + app.use(bodyParser.json()); app.use(function bootstrap$prepareRequestResponse(req, res, next) {