lib/relaton_ietf/bibxml_parser.rb in relaton-ietf-1.13.6 vs lib/relaton_ietf/bibxml_parser.rb in relaton-ietf-1.13.7

- old
+ new

@@ -142,14 +142,14 @@ # @param [String, nil] sname surname # @param [String, nil] inits # # @return [Array<String, nil>] surname, initials, forename # - def parse_surname_initials(fname, sname, inits) + def parse_surname_initials(fname, sname, inits) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity regex = /(?:(?<name>\w{3,})\s)?(?<inits>(?:[A-Z]{1,2}(?:\.[\s-]?|\s))+)?/ - match = fname.match(regex) - surname = sname || fname.sub(regex, "").strip - initials = inits || match[:inits]&.strip - [surname, initials, match[:name]] + match = fname&.match(regex) + surname = sname || fname&.sub(regex, "")&.strip + initials = inits || (match && match[:inits]&.strip) + [surname, initials, (match && match[:name])] end end end