Skip to content

Commit 4e8bfed

Browse files
committed
Guard against server not returning a Content-Type (test-suite server, apparently).
This addresses issue #14.
1 parent 7dd3c49 commit 4e8bfed

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/json/ld/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def self.documentLoader(url, options = {})
493493
remote_document = RemoteDocument.new(parsed_url.to_s, response.body)
494494

495495
# If the input has been retrieved, the response has an HTTP Link Header [RFC5988] using the http://www.w3.org/ns/json-ld#context link relation and a content type of application/json or any media type with a +json suffix as defined in [RFC6839] except application/ld+json, update the active context using the Context Processing algorithm, passing the context referenced in the HTTP Link Header as local context. The HTTP Link Header is ignored for documents served as application/ld+json If multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context link relation are found, the promise is rejected with a JsonLdError whose code is set to multiple context link headers and processing is terminated.
496-
unless content_type.start_with?("application/ld+json")
496+
unless content_type.to_s.start_with?("application/ld+json")
497497
links = response["link"].to_s.
498498
split(",").
499499
map(&:strip).

spec/suite_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def documentLoader(url, options = {})
263263

264264
remote_document = JSON::LD::API::RemoteDocument.new(parsed_url.to_s, response.body)
265265

266-
unless content_type.start_with?("application/ld+json")
266+
unless content_type.to_s.start_with?("application/ld+json")
267267
links = response["link"].to_s.
268268
split(",").
269269
map(&:strip).

0 commit comments

Comments
 (0)