Skip to content

Commit

Permalink
Allow JSON-LD documents with multiple profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Feb 15, 2024
1 parent 622a87a commit b9d2ea1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/helpers/jsonld_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ def valid_activitypub_content_type?(response)

# When the mime type is `application/ld+json`, we need to check the profile,
# but `http.rb` does not parse it for us.
response.mime_type == 'application/ld+json' && response.headers[HTTP::Headers::CONTENT_TYPE]&.split(';')&.map(&:strip)&.include?('profile="https://www.w3.org/ns/activitystreams"')
return false unless response.mime_type == 'application/ld+json'

response.headers[HTTP::Headers::CONTENT_TYPE]&.split(';')&.map(&:strip)&.any? do |str|
str.start_with?('profile="') && str[9...-1].split.include?('https://www.w3.org/ns/activitystreams')
end
end

def body_to_json(body, compare_id: nil)
Expand Down

0 comments on commit b9d2ea1

Please sign in to comment.