Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prefer Enumerable#flat_map over .map.flatten chain #378

Merged
merged 1 commit into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/addressable/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,12 @@ def transform(name, value)
def ordered_variable_defaults
@ordered_variable_defaults ||= begin
expansions, _ = parse_template_pattern(pattern)
expansions.map do |capture|
expansions.flat_map do |capture|
_, _, varlist = *capture.match(EXPRESSION)
varlist.split(',').map do |varspec|
varspec[VARSPEC, 1]
end
end.flatten
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/addressable/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@ def self.normalize_component(component, character_class=
leave_re = if leave_encoded.length > 0
character_class = "#{character_class}%" unless character_class.include?('%')

"|%(?!#{leave_encoded.chars.map do |char|
"|%(?!#{leave_encoded.chars.flat_map do |char|
seq = SEQUENCE_ENCODING_TABLE[char]
[seq.upcase, seq.downcase]
end.flatten.join('|')})"
end.join('|')})"
end

character_class = /[^#{character_class}]#{leave_re}/
Expand Down