Browse Source

return type=unknown instead of error=no_content

pull/39/head
Aaron Parecki 5 years ago
parent
commit
097e999768
3 changed files with 28 additions and 3 deletions
  1. +4
    -3
      controllers/Parse.php
  2. +10
    -0
      tests/ParseTest.php
  3. +14
    -0
      tests/data/source.example.com/no-h-entry

+ 4
- 3
controllers/Parse.php View File

@ -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',
]
]);
}

+ 10
- 0
tests/ParseTest.php View File

@ -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);
}
}

+ 14
- 0
tests/data/source.example.com/no-h-entry View File

@ -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
<html>
<head>
<title>Test</title>
</head>
<body>
<p>This page has a link to <a href="http://target.example.com">target.example.com</a> and some <b>formatted text</b> but has no h-entry markup.</p>
</body>
</html>

Loading…
Cancel
Save