add htm to uri, use site.uri for screenshot

This commit is contained in:
Kyle Drake 2024-09-19 12:47:21 -05:00
parent 0e827319cd
commit 3a41029313
3 changed files with 4 additions and 4 deletions

View file

@ -1438,7 +1438,7 @@ class Site < Sequel::Model
return uri unless path
path = '' if path == '/' || path =~ ROOT_INDEX_HTML_REGEX
path = path.sub(%r{^/}, '').sub(%r{/index\.html$}, '/').sub(/\.html$/, '')
path = path.sub(%r{^/}, '').sub(%r{/index\.html?$}, '/').sub(/\.html?$/, '')
unless path.empty?
escaped_path = self.class.escape_path path

View file

@ -12,7 +12,7 @@ describe ScreenshotWorker do
base_host += ":#{uri.port}"
end
stub_request(:get, "#{base_host}/?url=#{site.uri}/#{path}&wait_time=#{ScreenshotWorker::PAGE_WAIT_TIME}").
stub_request(:get, "#{base_host}/?url=#{site.uri(path)}&wait_time=#{ScreenshotWorker::PAGE_WAIT_TIME}").
with(basic_auth: [uri.user, uri.password]).
to_return(status: 200, headers: {}, body: File.read('tests/files/img/screenshot.png'))

View file

@ -37,11 +37,11 @@ class ScreenshotWorker
uri = Addressable::URI.parse $config['screenshot_urls'].sample
api_user, api_password = uri.user, uri.password
uri = "#{uri.scheme}://#{uri.host}:#{uri.port}" + '?' + Rack::Utils.build_query(
url: Site.select(:username,:domain).where(username: username).first.uri + path,
url: site.uri(path),
wait_time: PAGE_WAIT_TIME
)
begin
base_image_tmpfile_path = "/tmp/#{SecureRandom.uuid}.png"