Skip to content

Commit

Permalink
DEV: Correct handling of empty Accept headers
Browse files Browse the repository at this point in the history
  • Loading branch information
pmusaraj committed Nov 28, 2024
1 parent ceb2d98 commit 589db66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/discourse_activity_pub/json_ld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def valid_content_type?(value)
end

def valid_accept?(value)
return false if value.blank?
value.split(",").compact.collect(&:strip).all? { |v| valid_content_type?(v) }
end

Expand Down
4 changes: 4 additions & 0 deletions spec/lib/discourse_activity_pub/json_ld_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
false,
)
end

it "does not validate empty accept headers" do
expect(described_class.valid_accept?(nil)).to eq(false)
end
end

describe "#address_json" do
Expand Down

0 comments on commit 589db66

Please sign in to comment.