Skip to content

Commit

Permalink
Document AUTHORITY regexp.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 7, 2020
1 parent a146b6a commit eb7de84
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/rack/request.rb
Expand Up @@ -403,6 +403,7 @@ def content_charset
def form_data?
type = media_type
meth = get_header(RACK_METHODOVERRIDE_ORIGINAL_METHOD) || get_header(REQUEST_METHOD)

(meth == POST && type.nil?) || FORM_DATA_MEDIA_TYPES.include?(type)
end

Expand Down Expand Up @@ -590,7 +591,22 @@ def split_header(value)
value ? value.strip.split(/[,\s]+/) : []
end

AUTHORITY = /(?<host>(\[(?<ip6>.*)\])|(?<ip4>[\d\.]+)|(?<name>[a-zA-Z0-9\.\-]+))(:(?<port>\d+))?/
AUTHORITY = /
# The host:
(?<host>
# An IPv6 address:
(\[(?<ip6>.*)\])
|
# An IPv4 address:
(?<ip4>[\d\.]+)
|
# A hostname:
(?<name>[a-zA-Z0-9\.\-]+)
)
# The optional port:
(:(?<port>\d+))?
/x

private_constant :AUTHORITY

def split_authority(authority)
Expand Down

0 comments on commit eb7de84

Please sign in to comment.