Skip to content
New issue

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

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

Already on GitHub? Sign in 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/addressable/template.rb
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
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