Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/remote_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@ def path
def cache_path
return @cache_path if @cache_path
dirname = File.dirname(normalize_path).delete_suffix("/")
cache_id = "#{@url.host}#{dirname}".tr("/", "-")
cache_id = to_cache_id("#{@url.host}#{dirname}")
query = @url.query
cache_id += "+#{to_cache_id(query)}" if query and not query.empty?
@cache_path = CachePath.new(cache_id)
end

def to_cache_id(s)
allow_list = "0-9A-Za-z._~=-"
s.tr("^#{allow_list}", "-")
end

def normalize_path
url_path = @url.path
url_path = "/" if url_path.empty?
Expand Down
2 changes: 1 addition & 1 deletion test/test-remote-input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_open_with_block_raised
data("no path", ["/example.com/data", "https://example.com"])
data("root", ["/example.com/data", "https://example.com/"])
data("file", ["/example.com/file", "https://example.com/file"])
data("query", ["/example.com/file", "https://example.com/file?a=b"])
data("query", ["/example.com+a=-/file", "https://example.com/file?a=+"])
data("directory", ["/example.com-a/data", "https://example.com/a/"])
data("nested file", ["/example.com-a/file", "https://example.com/a/file"])
data("deeply nested", ["/example.com-a-b/file", "https://example.com/a/b/file"])
Expand Down
Loading