From 186d67351705cfb99442ee3bea8fe11ea39ba20e Mon Sep 17 00:00:00 2001 From: Pol Date: Tue, 14 Apr 2015 17:01:01 +0200 Subject: [PATCH 1/2] Add the commas to the prettified JSON I recently came across that when copying the prettified response there were no comma separating the elements. This solves this problem. --- Resources/views/layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index ef5487f..6466040 100755 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -319,7 +319,7 @@ prettifiedJsonString = prettifiedJsonString.replace(/(\{|\[)\n/g, function(match, sectionOpenCharacter) { return getJsonCollapseHtml(sectionOpenCharacter) + '\n'; }); - return prettifiedJsonString.replace(/([^\[][\}\]]),?\n/g, '$1\n'); + return prettifiedJsonString.replace(/([^\[][\}\]])(,)?\n/g, '$1$2\n'); }; var prettifyResponse = function(text) { From 226e38851f8d258f8fd81cc0ec00cc256835ab60 Mon Sep 17 00:00:00 2001 From: Pol Date: Tue, 14 Apr 2015 17:10:09 +0200 Subject: [PATCH 2/2] Optimization on the regex --- Resources/views/layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index 6466040..978662f 100755 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -319,7 +319,7 @@ prettifiedJsonString = prettifiedJsonString.replace(/(\{|\[)\n/g, function(match, sectionOpenCharacter) { return getJsonCollapseHtml(sectionOpenCharacter) + '\n'; }); - return prettifiedJsonString.replace(/([^\[][\}\]])(,)?\n/g, '$1$2\n'); + return prettifiedJsonString.replace(/([^\[][\}\]],?)\n/g, '$1\n'); }; var prettifyResponse = function(text) {