Skip to content

Commit

Permalink
Merge pull request #89 from upenn-libraries/NPE_in_catalog_bento_html…
Browse files Browse the repository at this point in the history
…_parse

fix repeated parsing, NPE in catalog bento html parsing
  • Loading branch information
magibney authored Sep 29, 2020
2 parents d0fbdb0 + 6c5c953 commit 68ea0e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/search_engines/bento_search/catalog_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ def search_implementation(args)
holdings = JSON.parse(holdings_response.body)

# TODO: Get a hidden reference to this value into the atom payload so it is referencable from the summary variable
if Oga.parse_html(entry['summary']).at_xpath('//a/@href').present?
online_resource[Oga.parse_html(entry['summary']).at_xpath('//a/@href').text] = Oga.parse_html(entry['summary']).at_xpath('//a/text()').text.strip
parsed_summary = Oga.parse_html(entry['summary'])
link = parsed_summary.at_xpath('//a')
if link
# If a link exists, we are not opinionated about what it must be. e.g., if href.nil? || href=='', we just pass
# it along. The exception is that we generate placeholder link text if none is present, to ensure that any
# links generated downstream will be visible/clickable.
href = link.attribute('href').to_s
online_resource[href] = link.text.strip.presence || '[no link text]'
end

holdings_string = mms_id.downcase.start_with?("hathi") ? '' : determine_holdings_status(holdings, mms_id, online_resource)
Expand Down

0 comments on commit 68ea0e4

Please sign in to comment.