From 097e999768bf446db1da24a66bdef209624c471d Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sat, 27 Feb 2016 17:10:43 -0800 Subject: [PATCH] return type=unknown instead of error=no_content --- controllers/Parse.php | 7 ++++--- tests/ParseTest.php | 10 ++++++++++ tests/data/source.example.com/no-h-entry | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/data/source.example.com/no-h-entry diff --git a/controllers/Parse.php b/controllers/Parse.php index d38be86..3e89f8f 100644 --- a/controllers/Parse.php +++ b/controllers/Parse.php @@ -125,9 +125,10 @@ class Parse { // TODO: look for other content like OEmbed or other known services later - return $this->respond($response, 400, [ - 'error' => 'no_content', - 'error_description' => 'No usable content could be found at the given URL' + return $this->respond($response, 200, [ + 'data' => [ + 'type' => 'unknown', + ] ]); } diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 93049c2..b96721e 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -118,4 +118,14 @@ class ParseTest extends PHPUnit_Framework_TestCase { $this->assertObjectNotHasAttribute('content', $data->data); } + public function testNoHEntryMarkup() { + $url = 'http://source.example.com/no-h-entry'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('unknown', $data->data->type); + } + } \ No newline at end of file diff --git a/tests/data/source.example.com/no-h-entry b/tests/data/source.example.com/no-h-entry new file mode 100644 index 0000000..f0761ac --- /dev/null +++ b/tests/data/source.example.com/no-h-entry @@ -0,0 +1,14 @@ +HTTP/1.1 200 OK +Server: Apache +Date: Wed, 09 Dec 2015 03:29:14 GMT +Content-Type: text/html; charset=utf-8 +Connection: keep-alive + + + + Test + + +

This page has a link to target.example.com and some formatted text but has no h-entry markup.

+ +