Skip to content

Commit a8ec53d

Browse files
committed
Refactor private matches_from_headers method
- improved documentation - use `filter_map` now that Ruby 2.7 is the minimum
1 parent feb119b commit a8ec53d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/indieweb/endpoints/parser.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ def matches_from_body(identifier, node_names)
7474
body.css(selectors).map { |element| element["href"] }
7575
end
7676

77+
# Reject URLs with fragment identifiers per the IndieAuth specification.
78+
#
79+
# @param identifier [String, #to_sym]
80+
#
7781
# @return [Array<String>]
7882
def matches_from_headers(identifier)
79-
# Reject endpoints that contain a fragment identifier.
80-
Array(headers[identifier.to_sym])
81-
.filter { |header| !HTTP::URI.parse(header.target_uri).fragment }
82-
.map(&:target_uri)
83+
Array(headers[identifier.to_sym]).filter_map do |header|
84+
header.target_uri unless HTTP::URI.parse(header.target_uri).fragment
85+
end
8386
end
8487
end
8588
end

0 commit comments

Comments
 (0)