From ee7fa9765474237e40917d32ab3bcd1d3c0bcbfb Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sat, 15 Apr 2017 10:19:27 -0700 Subject: [PATCH] skip parsing xkcd home page --- controllers/Parse.php | 2 +- lib/Formats/XKCD.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/Parse.php b/controllers/Parse.php index 81a54a2..50047fa 100644 --- a/controllers/Parse.php +++ b/controllers/Parse.php @@ -179,7 +179,7 @@ class Parse { return $this->respond($response, 200, $data); } - if($host == 'xkcd.com') { + if($host == 'xkcd.com' && parse_url($url, PHP_URL_PATH) != '/') { $data = Formats\XKCD::parse($result['body'], $url); $data['url'] = $result['url']; $data['code'] = $result['code']; diff --git a/lib/Formats/XKCD.php b/lib/Formats/XKCD.php index adfefb3..07de5c5 100644 --- a/lib/Formats/XKCD.php +++ b/lib/Formats/XKCD.php @@ -25,6 +25,10 @@ class XKCD { ]; $name = $doc->getElementById('ctitle'); + + if(!$name) + return self::_unknown(); + $entry['name'] = $name->nodeValue; $photo = $xpath->query("//div[@id='comic']/img");