grover 1.2.2 → 1.2.4
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/lib/grover/js/processor.cjs +11 -1
- data/lib/grover/middleware.rb +19 -9
- data/lib/grover/version.rb +1 -1
- 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: 5802a16dce1cb3dea2a458c546aa944244348700a620bc7f457922929eddf4ac
|
|
4
|
+
data.tar.gz: 91106f24cc30484d869cb19d35bf2a850851cee760cb1cb5ad1ce33a5d0a3db3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 913c5292ae47d73bdd0e2298dbec7b0e89673371a486dcb82433f7a8e722414d50268fbcef5f724acef609f7bfe9c022c1527d150415d56b3434cfed309ce2b1
|
|
7
|
+
data.tar.gz: 5e2bb65db4893f6530a7eaed7b992078e639ee50e41a6e4234fc34c2d49666a47136772555d9993fb38b05f27e4cd5eff5ee60a82030d6640da818c1201f545b
|
data/lib/grover/js/processor.cjs
CHANGED
|
@@ -92,6 +92,12 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
|
92
92
|
launchParams.args = launchParams.args.concat(args);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// Set browser type if given
|
|
96
|
+
const browserType = options.browser; delete options.browser;
|
|
97
|
+
if (browserType) {
|
|
98
|
+
launchParams.browser = browserType;
|
|
99
|
+
}
|
|
100
|
+
|
|
95
101
|
// Set executable path if given
|
|
96
102
|
const executablePath = options.executablePath; delete options.executablePath;
|
|
97
103
|
if (executablePath) {
|
|
@@ -114,7 +120,11 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
|
114
120
|
// Setting cookies
|
|
115
121
|
const cookies = options.cookies; delete options.cookies
|
|
116
122
|
if (Array.isArray(cookies)) {
|
|
117
|
-
|
|
123
|
+
if (typeof browser.setCookie === 'function') {
|
|
124
|
+
await browser.setCookie(...cookies);
|
|
125
|
+
} else if (typeof page.setCookie === 'function') {
|
|
126
|
+
await page.setCookie(...cookies);
|
|
127
|
+
}
|
|
118
128
|
}
|
|
119
129
|
|
|
120
130
|
// Set caching flag (if provided)
|
data/lib/grover/middleware.rb
CHANGED
|
@@ -8,6 +8,13 @@ class Grover
|
|
|
8
8
|
# @see https://github.com/pdfkit/pdfkit
|
|
9
9
|
#
|
|
10
10
|
class Middleware # rubocop:disable Metrics/ClassLength
|
|
11
|
+
PDF_REGEX = /\.pdf$/i
|
|
12
|
+
private_constant :PDF_REGEX
|
|
13
|
+
PNG_REGEX = /\.png$/i
|
|
14
|
+
private_constant :PNG_REGEX
|
|
15
|
+
JPEG_REGEX = /\.jpe?g$/i
|
|
16
|
+
private_constant :JPEG_REGEX
|
|
17
|
+
|
|
11
18
|
def initialize(app, *args)
|
|
12
19
|
@app = app
|
|
13
20
|
@pdf_request = false
|
|
@@ -40,10 +47,6 @@ class Grover
|
|
|
40
47
|
|
|
41
48
|
private
|
|
42
49
|
|
|
43
|
-
PDF_REGEX = /\.pdf$/i
|
|
44
|
-
PNG_REGEX = /\.png$/i
|
|
45
|
-
JPEG_REGEX = /\.jpe?g$/i
|
|
46
|
-
|
|
47
50
|
attr_reader :pdf_request, :png_request, :jpeg_request
|
|
48
51
|
|
|
49
52
|
def check_file_uri_configuration
|
|
@@ -85,7 +88,7 @@ class Grover
|
|
|
85
88
|
end
|
|
86
89
|
|
|
87
90
|
def html_content?(headers)
|
|
88
|
-
headers['content-type'] =~ %r{text/html|application/xhtml\+xml}
|
|
91
|
+
headers[lower_case_headers? ? 'content-type' : 'Content-Type'] =~ %r{text/html|application/xhtml\+xml}
|
|
89
92
|
end
|
|
90
93
|
|
|
91
94
|
def update_response(response, headers)
|
|
@@ -155,11 +158,12 @@ class Grover
|
|
|
155
158
|
|
|
156
159
|
def assign_headers(headers, body, content_type)
|
|
157
160
|
# Do not cache results
|
|
158
|
-
headers.delete 'etag'
|
|
159
|
-
headers.delete 'cache-control'
|
|
161
|
+
headers.delete(lower_case_headers? ? 'etag' : 'ETag')
|
|
162
|
+
headers.delete(lower_case_headers? ? 'cache-control' : 'Cache-Control')
|
|
160
163
|
|
|
161
|
-
headers['content-length'
|
|
162
|
-
|
|
164
|
+
headers[lower_case_headers? ? 'content-length' : 'Content-Length'] =
|
|
165
|
+
(body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
|
|
166
|
+
headers[lower_case_headers? ? 'content-type' : 'Content-Type'] = content_type
|
|
163
167
|
end
|
|
164
168
|
|
|
165
169
|
def configure_env_for_grover_request(env)
|
|
@@ -223,5 +227,11 @@ class Grover
|
|
|
223
227
|
env.delete 'CONTENT_LENGTH'
|
|
224
228
|
env.delete 'RAW_POST_DATA'
|
|
225
229
|
end
|
|
230
|
+
|
|
231
|
+
def lower_case_headers?
|
|
232
|
+
return @lower_case_headers if defined? @lower_case_headers
|
|
233
|
+
|
|
234
|
+
@lower_case_headers = Gem::Version.new(Rack.release) >= Gem::Version.new('3')
|
|
235
|
+
end
|
|
226
236
|
end
|
|
227
237
|
end
|
data/lib/grover/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: grover
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Bromwich
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|