indieweb-endpoints 9.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/indieweb-endpoints.gemspec +3 -3
- data/lib/indieweb/endpoints/client.rb +19 -15
- data/lib/indieweb/endpoints/parser.rb +17 -15
- data/lib/indieweb/endpoints.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764739f3fcfca374be14b10f42cfccd20999e0093ec2826399c94e0b91f40b55
|
4
|
+
data.tar.gz: f335bee04586d8de22137db8b2fb0910916c727a8e20da9694ddcf64bf2f75d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be93d73d8413292eee19bb40443da2cd29f6cdab989a18e66e27a7521e2c68550b8a7b161a79087228c1e24751513e8ca779eedf53b361096fa8aea58ba6f8d9
|
7
|
+
data.tar.gz: 5d634b748429d8e5161a09920481462fcc97c670e5d275e9ff6a9c4c14157216a7ba674f35c37755607891d63247e3f6467573afddffafca8eeb9360dc7b98c0
|
data/README.md
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
|
11
11
|
- Compliant with [Section 4.1](https://www.w3.org/TR/indieauth/#discovery-by-clients) and [Section 4.2.2](https://www.w3.org/TR/indieauth/#redirect-url) of [the W3C's IndieAuth Working Group Note](https://www.w3.org/TR/indieauth/), [Section 5.3](https://www.w3.org/TR/micropub/#endpoint-discovery) of [the W3C's Micropub Recommendation](https://www.w3.org/TR/micropub/), and [Section 3.1.2](https://www.w3.org/TR/webmention/#sender-discovers-receiver-webmention-endpoint) of [the W3C's Webmention Recommendation](https://www.w3.org/TR/webmention/).
|
12
12
|
- Passes all Endpoint Discovery tests on [webmention.rocks](https://webmention.rocks).
|
13
|
-
- Supports Ruby 2.
|
13
|
+
- Supports Ruby 2.7 and newer.
|
14
14
|
|
15
15
|
## Getting Started
|
16
16
|
|
17
|
-
Before installing and using indieweb-endpoints-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.
|
17
|
+
Before installing and using indieweb-endpoints-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.7 (or newer) installed. Using a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm) is recommended.
|
18
18
|
|
19
19
|
indieweb-endpoints-ruby is developed using Ruby 3.4 and is tested against additional Ruby versions using [GitHub Actions](https://github.com/indieweb/indieweb-endpoints-ruby/actions).
|
20
20
|
|
data/indieweb-endpoints.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.required_ruby_version = ">= 2.
|
4
|
+
spec.required_ruby_version = ">= 2.7"
|
5
5
|
|
6
6
|
spec.name = "indieweb-endpoints"
|
7
|
-
spec.version = "
|
7
|
+
spec.version = "10.0.0"
|
8
8
|
spec.authors = ["Jason Garber"]
|
9
9
|
spec.email = ["jason@sixtwothree.org"]
|
10
10
|
|
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "http", "~> 5.2"
|
32
32
|
spec.add_dependency "link-header-parser", "~> 6.1"
|
33
|
-
spec.add_dependency "nokogiri", "
|
33
|
+
spec.add_dependency "nokogiri-html-ext", "~> 1.4"
|
34
34
|
end
|
@@ -3,13 +3,6 @@
|
|
3
3
|
module IndieWeb
|
4
4
|
module Endpoints
|
5
5
|
class Client
|
6
|
-
HTTP_HEADERS_OPTS = {
|
7
|
-
accept: "*/*",
|
8
|
-
user_agent: "IndieWeb Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)",
|
9
|
-
}.freeze
|
10
|
-
|
11
|
-
private_constant :HTTP_HEADERS_OPTS
|
12
|
-
|
13
6
|
# Create a new client with a URL to parse for IndieWeb endpoints.
|
14
7
|
#
|
15
8
|
# @example
|
@@ -19,15 +12,20 @@ module IndieWeb
|
|
19
12
|
#
|
20
13
|
# @raise [InvalidURIError]
|
21
14
|
def initialize(url)
|
22
|
-
@uri = HTTP::URI.parse(url
|
15
|
+
@uri = HTTP::URI.parse(url)
|
23
16
|
rescue Addressable::URI::InvalidURIError => e
|
24
17
|
raise InvalidURIError, e
|
25
18
|
end
|
26
19
|
|
20
|
+
# :nocov:
|
27
21
|
# @return [String]
|
28
22
|
def inspect
|
29
|
-
|
23
|
+
format "#<%<class>s:%<id>#018x @uri=%<uri>s",
|
24
|
+
class: self.class,
|
25
|
+
id: object_id << 1,
|
26
|
+
uri: uri.inspect
|
30
27
|
end
|
28
|
+
# :nocov:
|
31
29
|
|
32
30
|
# A Hash of the discovered IndieWeb endpoints from the provided URL.
|
33
31
|
#
|
@@ -36,17 +34,18 @@ module IndieWeb
|
|
36
34
|
@endpoints ||= Parser.new(response).to_h
|
37
35
|
end
|
38
36
|
|
39
|
-
# The
|
37
|
+
# The +HTTP::Response+ object.
|
40
38
|
#
|
41
39
|
# @return [HTTP::Response]
|
42
40
|
#
|
43
41
|
# @raise [HttpError, SSLError]
|
44
42
|
def response
|
45
|
-
@response ||=
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
@response ||=
|
44
|
+
HTTP
|
45
|
+
.follow(max_hops: 20)
|
46
|
+
.headers(accept: "*/*", user_agent: user_agent)
|
47
|
+
.timeout(connect: 5, read: 5)
|
48
|
+
.get(uri)
|
50
49
|
rescue HTTP::Error => e
|
51
50
|
raise HttpError, e
|
52
51
|
rescue OpenSSL::SSL::SSLError => e
|
@@ -57,6 +56,11 @@ module IndieWeb
|
|
57
56
|
|
58
57
|
# @return [HTTP::URI]
|
59
58
|
attr_reader :uri
|
59
|
+
|
60
|
+
# @return [String]
|
61
|
+
def user_agent
|
62
|
+
"Mozilla/5.0 (compatible; IndieWebEndpointsDiscovery/1.0; +https://rubygems.org/gems/indieweb-endpoints)"
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end
|
62
66
|
end
|
@@ -16,17 +16,12 @@ module IndieWeb
|
|
16
16
|
#
|
17
17
|
# @raise [InvalidURIError]
|
18
18
|
def matches(identifier, node_names: ["link"])
|
19
|
-
results =
|
20
|
-
(matches_from_headers(identifier) + matches_from_body(identifier, node_names))
|
21
|
-
.compact
|
22
|
-
.map! { |endpoint| response.uri.join(endpoint).to_s }
|
19
|
+
results = (matches_from_headers(identifier) + matches_from_body(identifier, node_names)).compact
|
23
20
|
|
24
21
|
results.uniq!
|
25
22
|
results.sort!
|
26
23
|
|
27
24
|
results
|
28
|
-
rescue Addressable::URI::InvalidURIError => e
|
29
|
-
raise InvalidURIError, e
|
30
25
|
end
|
31
26
|
|
32
27
|
# @param (see #matches)
|
@@ -56,7 +51,7 @@ module IndieWeb
|
|
56
51
|
|
57
52
|
# @return [Nokogiri::HTML5::Document]
|
58
53
|
def body
|
59
|
-
@body ||= Nokogiri::HTML5(response.body)
|
54
|
+
@body ||= Nokogiri::HTML5(response.body, response.uri).resolve_relative_urls!
|
60
55
|
end
|
61
56
|
|
62
57
|
# @return [Hash{Symbol => Array<LinkHeaderParser::LinkHeader>}]
|
@@ -64,22 +59,29 @@ module IndieWeb
|
|
64
59
|
@headers ||= LinkHeaderParser.parse(response.headers.get("link"), base: response.uri).group_by_relation_type
|
65
60
|
end
|
66
61
|
|
62
|
+
# Reject URLs with fragment identifiers per the IndieAuth specification.
|
63
|
+
#
|
64
|
+
# @param identifier [String, #to_s]
|
65
|
+
# @param node_names [Array<String, #to_s>]
|
66
|
+
#
|
67
67
|
# @return [Array<String>]
|
68
68
|
def matches_from_body(identifier, node_names)
|
69
69
|
return [] unless response.mime_type == "text/html"
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
body.css(selectors).map { |element| element["href"] }
|
71
|
+
body
|
72
|
+
.css(*node_names.map { |node| %(#{node}[rel~="#{identifier}"][href]:not([href*="#"]) / @href) })
|
73
|
+
.map(&:value)
|
75
74
|
end
|
76
75
|
|
76
|
+
# Reject URLs with fragment identifiers per the IndieAuth specification.
|
77
|
+
#
|
78
|
+
# @param identifier [String, #to_sym]
|
79
|
+
#
|
77
80
|
# @return [Array<String>]
|
78
81
|
def matches_from_headers(identifier)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
.map(&:target_uri)
|
82
|
+
Array(headers[identifier.to_sym]).filter_map do |header|
|
83
|
+
header.target_uri unless HTTP::URI.parse(header.target_uri).fragment
|
84
|
+
end
|
83
85
|
end
|
84
86
|
end
|
85
87
|
end
|
data/lib/indieweb/endpoints.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indieweb-endpoints
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Garber
|
@@ -38,19 +38,19 @@ dependencies:
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '6.1'
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name: nokogiri
|
41
|
+
name: nokogiri-html-ext
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.4'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '1.
|
53
|
+
version: '1.4'
|
54
54
|
description: Discover a URL’s IndieAuth, Micropub, Microsub, and Webmention endpoints.
|
55
55
|
email:
|
56
56
|
- jason@sixtwothree.org
|
@@ -72,11 +72,11 @@ licenses:
|
|
72
72
|
- MIT
|
73
73
|
metadata:
|
74
74
|
bug_tracker_uri: https://github.com/indieweb/indieweb-endpoints-ruby/issues
|
75
|
-
changelog_uri: https://github.com/indieweb/indieweb-endpoints-ruby/releases/tag/
|
76
|
-
documentation_uri: https://rubydoc.info/gems/indieweb-endpoints/
|
75
|
+
changelog_uri: https://github.com/indieweb/indieweb-endpoints-ruby/releases/tag/v10.0.0
|
76
|
+
documentation_uri: https://rubydoc.info/gems/indieweb-endpoints/10.0.0
|
77
77
|
homepage_uri: https://github.com/indieweb/indieweb-endpoints-ruby
|
78
78
|
rubygems_mfa_required: 'true'
|
79
|
-
source_code_uri: https://github.com/indieweb/indieweb-endpoints-ruby/tree/
|
79
|
+
source_code_uri: https://github.com/indieweb/indieweb-endpoints-ruby/tree/v10.0.0
|
80
80
|
rdoc_options: []
|
81
81
|
require_paths:
|
82
82
|
- lib
|
@@ -84,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
85
85
|
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '2.
|
87
|
+
version: '2.7'
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - ">="
|