linkheaders-processor 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/linkheaders/processor/version.rb +1 -1
- data/lib/linkheaders/processor.rb +17 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88db7265719e8b2f1d6fa9f804d6970dc411f6ff609cdff6fbf21f9e904d76d8
|
4
|
+
data.tar.gz: b504685f471206e45bae949bc3f423c2ed9e9aedca7c0d27784c5ca6d6a78e02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1973c63103587b077879d1d53fa50cc5f9b1102a3dd8db2e56d792ceaa0d60addcb8a3edeb50069fa3263c2f4820e09cdd9714579c4d0b119ab2cbbe5e44122
|
7
|
+
data.tar.gz: ce8c65a0e657430caca6abff60c435aa79bc659f6623017ddb9d7e90d2988c7f51650ca7f89df58b2c5db2a1b904c8137da7c66c1557d08f80208304cef6ba8d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
linkheaders-processor (0.1.
|
4
|
+
linkheaders-processor (0.1.21)
|
5
5
|
json (~> 2.0)
|
6
6
|
json-ld (~> 3.2)
|
7
7
|
json-ld-preloaded (~> 3.2)
|
@@ -134,7 +134,7 @@ GEM
|
|
134
134
|
parser (>= 3.1.1.0)
|
135
135
|
ruby-progressbar (1.11.0)
|
136
136
|
ruby2_keywords (0.0.5)
|
137
|
-
securerandom (0.
|
137
|
+
securerandom (0.2.2)
|
138
138
|
unf (0.1.4)
|
139
139
|
unf_ext
|
140
140
|
unf_ext (0.0.8.2)
|
@@ -96,28 +96,33 @@ module LinkHeaders
|
|
96
96
|
def split_http_link_headers_and_process(parts)
|
97
97
|
newlinks = Array.new
|
98
98
|
parts.each do |part, _index|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
99
|
+
warn "link is: #{part}" # <https://s11.no/2022/a2a-fair-metrics/70-rda-r1-01m-t2-type-charset/test-apple-data.csv>;rel="item";type="text/csv;charset=UTF-8"
|
100
|
+
|
101
|
+
# this is crazy hard, because we can't rely on quotes!
|
102
|
+
part = part + ";"
|
103
|
+
href = part[/<([^\]]+)>;/, 1]
|
104
|
+
next unless href
|
105
|
+
part = part.gsub(/<([^\]]+)>\s?;\s?/, "") # now only ;rel="item";type="text/csv;charset=UTF-8"; pro=gram
|
106
|
+
pieces = part.scan(/(\S+?\s?=\s?"[^"]+?"\s?);?/).flatten # ["rel=\"item\"", "type=\"text/csv;charset=UTF-8\""] and the non-quoted stuff is ignored
|
107
|
+
pieces.each do |p|
|
108
|
+
part = part.gsub(p, "") # now just ";;prog=gram;"
|
109
|
+
end
|
110
|
+
rest = part.split(";") # ["", "", "prog=gram"]
|
109
111
|
|
110
112
|
sections = {}
|
111
|
-
|
113
|
+
pieces.concat(rest).each do |s| # can be more than one link property "rel='preconnect'"
|
112
114
|
s.strip!
|
113
|
-
unless m = s.match(%r{(\w+?)
|
115
|
+
unless m = s.match(%r{(\w+?)\s?=\s?"?([\w\;\:\d\.\,\=\#\-\+\/\s]+)"?})
|
116
|
+
warn " NO PATTERN MATCH ON #{s}"
|
114
117
|
next
|
115
118
|
end # can be rel="cite-as describedby" --> two relations in one! or "linkset+json"
|
116
119
|
|
117
120
|
relation = m[1] # rel"
|
118
121
|
value = m[2] # "preconnect"
|
122
|
+
warn "section relation #{relation} value #{value}"
|
119
123
|
sections[relation] = value # value could hold multiple relation types sections[:rel] = "preconnect"
|
120
124
|
end
|
125
|
+
|
121
126
|
next unless sections['rel'] # the relation is required!
|
122
127
|
|
123
128
|
anchor = sections['anchor'] || default_anchor
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkheaders-processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Wilkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|