Skip to content

Instantly share code, notes, and snippets.

@jkrems
Created August 20, 2015 17:48
Show Gist options
  • Save jkrems/5f08ab53c05d96356a1e to your computer and use it in GitHub Desktop.
Save jkrems/5f08ab53c05d96356a1e to your computer and use it in GitHub Desktop.
Devtools doesn't format JSON responses when they have trailing whitespace
diff --git a/Source/devtools/front_end/network/RequestJSONView.js b/Source/devtools/front_end/network/RequestJSONView.js
index f88c212..a5b3eed 100644
--- a/Source/devtools/front_end/network/RequestJSONView.js
+++ b/Source/devtools/front_end/network/RequestJSONView.js
@@ -152,7 +152,7 @@ WebInspector.RequestJSONView.parseJSON = function(text)
text = text.substring(inner.start, inner.end + 1);
// Only process valid JSONP.
- if (suffix.length && !(suffix.trim().startsWith(")") && prefix.trim().endsWith("(")))
+ if (suffix.trim().length && !(suffix.trim().startsWith(")") && prefix.trim().endsWith("(")))
return null;
try {
@jkrems
Copy link
Author

jkrems commented Aug 20, 2015

Example: {"ok":true}\n won't be formatted currently but would be with this fix.

@paulirish
Copy link

oh! good fix. i can land this.

@jkrems
Copy link
Author

jkrems commented Aug 20, 2015

Thanks! :)

@paulirish
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment