fixed problem in http redirect paywall detection

This commit is contained in:
tigerbot 2017-07-10 17:06:34 -06:00
parent 1957dd8d80
commit 2ffd846352
1 changed files with 4 additions and 3 deletions

View File

@ -63,6 +63,7 @@ module.exports.create = function (deps, conf) {
} }
function checkPaywall() { function checkPaywall() {
var url = require('url');
var PromiseA = require('bluebird'); var PromiseA = require('bluebird');
var testDomains = [ var testDomains = [
'daplie.com' 'daplie.com'
@ -118,11 +119,11 @@ module.exports.create = function (deps, conf) {
}); });
var proms = testDomains.map(function (dom) { var proms = testDomains.map(function (dom) {
return request('https://'+dom).then(function (resp) { return request('http://'+dom).then(function (resp) {
if (resp.statusCode >= 300 && resp.statusCode < 400) { if (resp.statusCode >= 300 && resp.statusCode < 400) {
return resp.headers.location; return url.parse(resp.headers.location).hostname;
} else { } else {
return 'https://'+dom; return dom;
} }
}); });
}); });