Skip to content

Commit 272983c

Browse files
karlcowMike Taylor
authored and
Mike Taylor
committed
#451 Adjusting comments
1 parent f7601fe commit 272983c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

webcompat/helpers.py

+4
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,20 @@ def parse_link_header(link_header):
239239
'''Return a structured list of objects for an HTTP Link header.
240240
241241
This is adjusted for github links it will break in a more generic case.
242+
Do not use this code for your own HTTP Link header parsing.
242243
Use something like https://pypi.python.org/pypi/LinkHeader/ instead.
243244
'''
244245
links_list = link_header.split(',')
245246
header_link_data = []
246247
for link in links_list:
248+
# Assuming that link is `<uri>; rel="blah"`. Github only.
247249
uri_info, rel_info = link.split(';')
248250
uri_info = uri_info.strip()
249251
rel_info = rel_info.strip()
250252
rel = rel_info.split('=')
251253
rel_value = rel[1][1:-1]
254+
# rel values have the form `rel="foo"`, we want `foo`.
255+
# uri have the form `<http://…>`, we want `http://…`.
252256
uri = uri_info[1:-1]
253257
header_link_data.append({'link': uri, 'rel': rel_value})
254258
return header_link_data

0 commit comments

Comments
 (0)