This website works better with JavaScript.
Home
Explore
Help
Sign In
p3k
/
XRay
mirror of
https://github.com/aaronpk/XRay.git
Watch
1
Star
0
Fork
0
Code
Issues
0
Releases
77
Wiki
Activity
Browse Source
add bookmark-of property for hackernews posts
main
Aaron Parecki
1 year ago
parent
55fff0875b
commit
9c0a8ba48b
3 changed files
with
32 additions
and
1 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+5
-1
lib/XRay/Formats/Hackernews.php
+16
-0
tests/HackernewsTest.php
+11
-0
tests/data/hacker-news.firebaseio.com/v0_item_27402392.json
+ 5
- 1
lib/XRay/Formats/Hackernews.php
View File
@ -61,9 +61,13 @@ class Hackernews extends Format {
'photo'
=>
null
,
'url'
=>
'https://news.ycombinator.com/user?id='
.
$data
[
'by'
]
],
'published'
=>
$date
->
format
(
'c'
)
'published'
=>
$date
->
format
(
'c'
)
,
);
if
(
isset
(
$data
[
'url'
]))
{
$entry
[
'bookmark-of'
]
=
[
$data
[
'url'
]];
}
if
(
isset
(
$data
[
'title'
]))
{
$entry
[
'name'
]
=
$data
[
'title'
];
}
+ 16
- 0
tests/HackernewsTest.php
View File
@ -21,6 +21,22 @@ class HackernewsTest extends PHPUnit\Framework\TestCase
return
$this
->
client
->
parse
(
$request
,
$response
);
}
public
function
testBookmark
()
{
$url
=
'https://news.ycombinator.com/item?id=27402392'
;
$response
=
$this
->
parse
([
'url'
=>
$url
]);
$body
=
$response
->
getContent
();
$this
->
assertEquals
(
200
,
$response
->
getStatusCode
());
$data
=
json_decode
(
$body
,
true
);
$this
->
assertEquals
(
200
,
$data
[
'code'
]);
$this
->
assertEquals
(
'hackernews'
,
$data
[
'source-format'
]);
$this
->
assertEquals
([
'https://kevincox.ca/2021/06/04/http-range-caching/'
],
$data
[
'data'
][
'bookmark-of'
]);
$this
->
assertEquals
(
'The Impossibility of Perfectly Caching HTTP Range Requests'
,
$data
[
'data'
][
'name'
]);
}
public
function
testSubmission
()
{
$url
=
'https://news.ycombinator.com/item?id=14516538'
;
+ 11
- 0
tests/data/hacker-news.firebaseio.com/v0_item_27402392.json
View File
@ -0,0 +1,11 @@
H
T
T
P
/
1.1
200
O
K
S
e
r
v
e
r
:
n
g
i
n
x
D
a
t
e
:
F
r
i
,
0
9
J
u
n
2017
14
:
30
:
19
G
M
T
C
o
n
t
e
n
t
-
T
y
p
e
:
a
p
p
l
i
c
a
t
i
o
n
/
j
s
o
n
;
c
h
a
r
s
e
t
=
u
t
f
-8
C
o
n
t
e
n
t
-
L
e
n
g
t
h
:
1701
C
o
n
n
e
c
t
i
o
n
:
k
e
e
p
-
a
l
i
v
e
A
c
c
e
s
s
-
C
o
n
t
r
o
l
-
A
l
l
o
w
-
O
r
i
g
i
n
:
*
C
a
c
h
e
-
C
o
n
t
r
o
l
:
n
o
-
c
a
c
h
e
S
t
r
i
c
t
-
T
r
a
n
s
p
o
r
t
-
S
e
c
u
r
i
t
y
:
m
a
x
-
a
g
e
=
31556926
;
i
n
c
l
u
d
e
S
u
b
D
o
m
a
i
n
s
;
p
r
e
l
o
a
d
{
"by"
:
"giuliomagnifico"
,
"descendants"
:
0
,
"id"
:
27402392
,
"score"
:
2
,
"time"
:
1622869705
,
"title"
:
"The Impossibility of Perfectly Caching HTTP Range Requests"
,
"type"
:
"story"
,
"url"
:
"https://kevincox.ca/2021/06/04/http-range-caching/"
}
Write
Preview
Loading…
Cancel
Save