Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix content-type check #8

Open
wants to merge 1 commit into from

1 participant

@RSO
RSO commented

Rails returns "application/json; charset=utf-8" for content-type, this fixes get.js for this case.

@RSO RSO Fixed content-type check
Rails returns "application/json; charset=utf-8" for content-type, this fixes get.js for this case.
282e960
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 8, 2013
  1. @RSO

    Fixed content-type check

    RSO authored
    Rails returns "application/json; charset=utf-8" for content-type, this fixes get.js for this case.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  lib/node-get/node-get.js
View
3  lib/node-get/node-get.js
@@ -234,6 +234,9 @@ Get.prototype.asString = function(callback) {
if (err) return callback(err);
var mime = (response.headers['content-type'] || '').toLowerCase();
+ // Fix cases like:
+ // application/json; charset=utf-8
+ mime = mime.split(";")[0];
if (mime !== 'application/json') switch (mime.split('/')[0]) {
case 'binary':
case 'application':
Something went wrong with that request. Please try again.