Class: Micropub::Endpoint::Discover
- Inherits:
-
Object
- Object
- Micropub::Endpoint::Discover
- Defined in:
- lib/micropub/endpoint/discover.rb
Constant Summary collapse
- REGEXP_REG_REL_TYPE_PATTERN =
Ultra-orthodox pattern matching allowed values in HTTP Link header ‘rel` parameter tools.ietf.org/html/rfc8288#section-3.3
'[a-z\d][a-z\d\-\.]*'.freeze
- REGEXP_TARGET_URI_PATTERN =
Liberal pattern matching a string of text between angle brackets tools.ietf.org/html/rfc5988#section-5.1
/^<(.*)>;/.freeze
- REGEXP_MICROPUB_REL_PATTERN =
Ultra-orthodox pattern matching HTTP Link header ‘rel` parameter including a `micropub` value www.w3.org/TR/micropub/#endpoint-discovery
/(?:;|\s)rel="?(?:#{REGEXP_REG_REL_TYPE_PATTERN}+\s)?micropub(?:\s#{REGEXP_REG_REL_TYPE_PATTERN})?"?/.freeze
Instance Method Summary collapse
- #endpoint ⇒ Object
-
#initialize(response) ⇒ Discover
constructor
A new instance of Discover.
Constructor Details
#initialize(response) ⇒ Discover
Returns a new instance of Discover.
16 17 18 19 20 |
# File 'lib/micropub/endpoint/discover.rb', line 16 def initialize(response) raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response) @response = response end |
Instance Method Details
#endpoint ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/micropub/endpoint/discover.rb', line 22 def endpoint return unless endpoint_from_http_request @endpoint ||= Absolutely.to_absolute_uri(base: @response.uri.to_s, relative: endpoint_from_http_request) rescue Absolutely::InvalidURIError => error raise InvalidURIError, error end |