Skip to content

Commit 9f452e5

Browse files
committed
Addresses issue digitalbazaar#128 for requests document loader, typos
1 parent 15580a7 commit 9f452e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/pyld/documentloader/requests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
import string
1313
import re
1414
import urllib.parse as urllib_parse
15+
from json import JSONDecodeError
1516

16-
from pyld.jsonld import (JsonLdError, parse_link_header, LINK_HEADER_REL)
17+
from pyld.jsonld import (JsonLdError, parse_link_header, prepend_base, LINK_HEADER_REL)
1718

1819

1920
def requests_document_loader(secure=False, max_link_follows=2, **kwargs):
@@ -70,7 +71,7 @@ def loader(url, options={}, link_follow_count=0):
7071
}
7172
try:
7273
doc['document'] = response.json()
73-
except json.JSONDecodeError as e:
74+
except JSONDecodeError as e:
7475
# document body is not parseable, continue to check link headers
7576
pass
7677
# if content_type in headers['Accept']:
@@ -96,7 +97,7 @@ def loader(url, options={}, link_follow_count=0):
9697
linked_alternate.get('type') == 'application/ld+json' and
9798
not re.match(r'^application\/(\w*\+)?json$', content_type)):
9899
doc['contentType'] = 'application/ld+json'
99-
doc['documentUrl'] = jsonld.prepend_base(url, linked_alternate['target'])
100+
doc['documentUrl'] = prepend_base(url, linked_alternate['target'])
100101
if link_follow_count >= max_link_follows:
101102
raise requests.TooManyRedirects(f"Exceeded maximum link header redirects ({max_link_follows})")
102103
return loader(doc['documentUrl'], options=options, link_follow_count=link_follow_count + 1)

0 commit comments

Comments
 (0)