Skip to content

Commit 2c98dcf

Browse files
committed
fix: double-slashes with version prefix
1 parent 84bfdc0 commit 2c98dcf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/uptriever/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def documents
3232
File.join(config["url_prefix"], _1)
3333
end
3434

35-
link = page["link"] || File.join(config.fetch("hostname"), relative_link)
35+
link = (page["link"] || File.join(config.fetch("hostname"), relative_link)).gsub(/([^:])\/{2,}/, '\1/')
3636
id = page["id"] || relative_link.sub(/^\//, "").gsub(/[\/-]/, "-")
3737

3838
Document.new(id, page["source"], link, **defaults.merge({groups: page["groups"], tags: page["tags"], weight: page["weight"]}.compact))

test/config_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,14 @@ def test_erb
2626
ensure
2727
ENV.delete("URL_PREFIX")
2828
end
29+
30+
def test_double_slashes
31+
ENV["URL_PREFIX"] = "//latest/subpath"
32+
docs = @config.documents
33+
34+
assert_equal "https://docs.anycable.io/latest/subpath/js/setup", docs.first.link
35+
ensure
36+
ENV.delete("URL_PREFIX")
37+
end
2938
end
3039
end

0 commit comments

Comments
 (0)