Skip to content

Commit

Permalink
Make pingbackUrl optional in the config file
Browse files Browse the repository at this point in the history
Fixes #40
  • Loading branch information
nitriques committed Nov 26, 2018
1 parent 192743d commit 469f636
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/pingback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ const https = require('https');
const querystring = require('querystring');

module.exports = (config) => {
const cfg = config;
const url = cfg.url;
const parsedUrl = URL.parse(url);
const client = parsedUrl.protocol === 'https:' ? https : http;
const url = config.url;
const parsedUrl = !url ? null : URL.parse(url);

if (!parsedUrl.hostname) {
if (!parsedUrl || !parsedUrl.hostname) {
return {
ok: false,
error: 'No hostname found for ' + url,
Expand Down Expand Up @@ -49,8 +47,8 @@ module.exports = (config) => {
'Content-Length': postData.length
}
};

var req = client.request(httpOptions, (res) => {
const client = parsedUrl.protocol === 'https:' ? https : http;
const req = client.request(httpOptions, (res) => {
let data = '';
res.setEncoding('utf8');

Expand Down

0 comments on commit 469f636

Please sign in to comment.