From 185ecec0df3392d99548255c16d3e06c6a8917c9 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 9 Feb 2024 18:24:26 +0100 Subject: [PATCH] Allow JSON-LD documents with multiple profiles --- app/helpers/jsonld_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index fced54d85e..05de70970c 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -183,7 +183,11 @@ module JsonLdHelper # 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)