sul-dlss / SearchWorks

SearchWorks (Stanford University Libraries)
http://searchworks.stanford.edu
Other
48 stars 10 forks source link

fix included works parsing of marc, closes #3487 #4269

Closed dnoneill closed 3 months ago

dnoneill commented 3 months ago

before_t, after_t = relevant_subfields.slice_before { |subfield| subfield.code == 't' }.to_a within_t, extra_fields = after_t.flatten.slice_after { |subfield| subfield.value =~ /[.|;]\s*$/ }.to_a

Expect the result to be a list with two items in them. When slice_after doesn't find anything it returns an empty array [], not what it expects: [[], []]. This causes a problem when looping on the Included works field if there are items that aren't after the t field like the record 8113045. This has the subfields [#<MARC::Subfield:0x00000001725ae128 @code="t", @value="Works.">, #<MARC::Subfield:0x00000001725ae100 @code="f", @value="1999.">] which means within_t returns nil.