Skip to content

Commit

Permalink
Strip markup from selected facet values in the html title.
Browse files Browse the repository at this point in the history
- E.g., span/data-attributes rendered for selected range facet values by blacklight_range_limit
- Fixes projectblacklight/blacklight_range_limit#189
  • Loading branch information
seanaery committed Dec 6, 2024
1 parent a753cd9 commit 7df9af1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/blacklight/catalog_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def render_search_to_page_title_filter(facet, values)
else
t('blacklight.search.page_title.many_constraint_values', values: values.size)
end
t('blacklight.search.page_title.constraint', label: filter_label, value: filter_value)
t('blacklight.search.page_title.constraint', label: filter_label, value: strip_tags(filter_value))
end

# Render an html <title> appropriate string for a set of search parameters
Expand Down
4 changes: 4 additions & 0 deletions spec/helpers/catalog_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ def mock_response args
it "renders a facet with more than two values" do
expect(helper.render_search_to_page_title_filter('foo', %w[bar baz foobar])).to eq "Foo: 3 selected"
end

it "strips tags from values" do
expect(helper.render_search_to_page_title_filter('Year', ['<span class="from" data-blrl-begin="1990">1990</span> to <span class="to" data-blrl-end="1999">1999</span>'])).to eq "Year: 1990 to 1999"
end
end

describe "#render_search_to_page_title" do
Expand Down

0 comments on commit 7df9af1

Please sign in to comment.