lib/relaton_iso/iso_bibliography.rb in relaton-iso-1.2.0 vs lib/relaton_iso/iso_bibliography.rb in relaton-iso-1.2.1
- old
+ new
@@ -36,13 +36,14 @@
}x =~ opts[:ref]
code = code1 || opts[:ref]
if year.nil?
/^(?<code1>[^\s]+(\s\w+)?\s[\d-]+)(:(?<year1>\d{4}))?(?<code2>\s\w+)?/ =~ code
+ /:(?<year2>\d{4})/ =~ corr
unless code1.nil?
code = code1 + code2.to_s
- year = year1
+ year = year2 || year1
end
end
opts[:all_parts] ||= code !~ %r{^[^\s]+\s\d+-\d+} && opts[:all_parts].nil? && code2.nil?
return RelatonIec::IecBibliography.get(code, year, opts) if %r[^ISO/IEC DIR] =~ code
@@ -143,10 +144,10 @@
# Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
# If no match, returns any years which caused mismatch, for error reporting
def isobib_results_filter(result, year, opts)
missed_years = []
hits = result.reduce!([]) do |hts, h|
- if !year || %r{:(?<iyear>\d{4})} =~ h.hit["docRef"] && iyear == year
+ if !year || %r{:(?<iyear>\d{4})(?!.*:\d{4})} =~ h.hit["docRef"] && iyear == year
hts << h
else
missed_years << iyear
hts
end