From 5912e0c87207af097df080b344ec36b5a1c007ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 22 Apr 2015 17:16:43 +0200 Subject: [PATCH] Add Firefox User-Agent when generating the test case. --- test/generate-testcase.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/generate-testcase.js b/test/generate-testcase.js index 5dae3d2..ae9ba4d 100644 --- a/test/generate-testcase.js +++ b/test/generate-testcase.js @@ -6,11 +6,14 @@ var jsdom = require("jsdom").jsdom; var prettyPrint = require("./utils").prettyPrint; var serializeDocument = require("jsdom").serializeDocument; var http = require("http"); +var urlparse = require("url").parse; var readability = require("../index"); var Readability = readability.Readability; var JSDOMParser = readability.JSDOMParser; +var FFX_UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0"; + if (process.argv.length < 3) { console.error("Need at least a destination slug and potentially a URL (if the slug doesn't have source)."); process.exit(0); @@ -54,7 +57,10 @@ function fetchSource(url, callbackFn) { if (url.indexOf("https") == 0) { client = require("https"); } - client.get(url, function(response) { + var options = urlparse(url); + options.headers = {'User-Agent': FFX_UA}; + + client.get(options, function(response) { if (debug) { console.log("STATUS:", response.statusCode); console.log("HEADERS:", JSON.stringify(response.headers));