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");