Skip to content

Commit 699c977

Browse files
Fix duplicate web archive URL when retrying
fixes #46
1 parent 356297d commit 699c977

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
source "https://rubygems.org"
22

3-
gem 'concurrent-ruby', '~> 1.3', '>= 1.3.4'
3+
gem 'concurrent-ruby', '~> 1.3', '>= 1.3.6'
44
gemspec

lib/wayback_machine_downloader.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,10 +1122,14 @@ def safe_display_url(url)
11221122
def download_with_retry(file_path, file_url, file_timestamp, connection, redirect_count = 0)
11231123
retries = 0
11241124
begin
1125-
wayback_url = if @rewritten
1126-
"https://web.archive.org/web/#{file_timestamp}/#{file_url}"
1125+
if redirect_count > 0 && file_url =~ %r{\Ahttps?://}
1126+
wayback_url = file_url
11271127
else
1128-
"https://web.archive.org/web/#{file_timestamp}id_/#{file_url}"
1128+
wayback_url = if @rewritten
1129+
"https://web.archive.org/web/#{file_timestamp}/#{file_url}"
1130+
else
1131+
"https://web.archive.org/web/#{file_timestamp}id_/#{file_url}"
1132+
end
11291133
end
11301134

11311135
# Escape characters that are not valid in URI()

wayback_machine_downloader.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
1010
s.homepage = "https://github.com/StrawberryMaster/wayback-machine-downloader"
1111
s.license = "MIT"
1212
s.required_ruby_version = ">= 3.4.3"
13-
s.add_runtime_dependency "concurrent-ruby", "~> 1.3", ">= 1.3.4"
13+
s.add_runtime_dependency "concurrent-ruby", "~> 1.3", ">= 1.3.6"
1414
s.add_development_dependency "rake", "~> 12.2"
1515
s.add_development_dependency "minitest", "~> 5.2"
1616
end

0 commit comments

Comments
 (0)