Search code examples
javascriptnode.jsiso-8859-1zombie.js

Unknown encoding: iso-8859-1 error in Zombie.js


When I run zombie.js, I get the error:

Unknown encoding: iso-8859-1 TypeError: Unknown encoding: iso-8859-1 at Buffer.toString (buffer.js:432:13) at Browser.Resources.decodeBody (/Users/bendytree/projects/testzombie/node_modules/zombie/lib/zombie/resources.js:400:37)

Here is the code that causes the error:

var Browser = require("zombie");
var browser = new Browser()
browser.visit("http://www.amazon.com/", function () {
  console.log(browser.html());
});

Amazon is not the site I'm really using, but it serves well as an example since it is ISO-8859-1.

There's an issue on GitHub discussing the problem, but no workarounds are posted. The thread makes me think it was fixed, but I'm on the latest version of zombie ~2.0.0-alpha24 and it's still a problem.

Any ideas?


Solution

  • It looks like what happened was the ashaw created a "fix" for this in his own fork, and this was never picked up by assaf into the main project, so even while you're using the latest version it's not the one that has the "fix".

    Try using ashaw's fork (see here for the specific commit: https://github.com/ashaw/zombie/commit/675c78d3bb8696dc1eaf3d226187a7683a15d2a0).

    Also, assaf doesn't seem to think this is a good fix. Just saying.