Inject persistent top navbar (with printer switcher) into proxied Brother pages
This commit is contained in:
1 parent
daa39320a6
commit
1cc03d8451
3 files changed
+34
-22
No files matched your search
@@ -102,13 +102,18 @@ helpers do
|
||||
|
||||
res = Net::HTTP.start(uri.host, uri.port) { |http| http.request(proxied) }
|
||||
|
||||
body = res.body || ''
|
||||
if res['Content-Type']&.include?('text/html')
|
||||
body = body.sub(/(<body[^>]*>)/i) { "#{Regexp.last_match(1)}\n#{erb(:_navbar, layout: false)}" }
|
||||
end
|
||||
|
||||
headers = {}
|
||||
res.each_header do |key, value|
|
||||
next if %w[transfer-encoding connection content-length].include?(key.downcase)
|
||||
|
||||
headers[key] = value
|
||||
end
|
||||
[res.code.to_i, headers, [res.body || '']]
|
||||
[res.code.to_i, headers, [body]]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user