Skip to content

Commit

Permalink
escape square brackets in URI
Browse files Browse the repository at this point in the history
  • Loading branch information
sskylar committed Sep 15, 2020
1 parent 776bf9b commit 5b9739c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/siteleaf/source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ class SourceFile < Entity
attr_reader :name, :url, :download_url, :type, :filesize, :sha, :created_at, :updated_at, :user_id

def create_endpoint
::File.join("sites", site_id, "source", URI.escape(identifier))
uri = URI.encode(identifier)
uri = uri.gsub('[', '%5B').gsub(']', '%5D') # workaround for https://bugs.ruby-lang.org/issues/12235
::File.join('sites', site_id, 'source', uri)
end

def entity_endpoint
Expand All @@ -17,7 +19,7 @@ def identifier
end

def to_file
Client.get(::File.join("sites", site_id, "source", "#{URI.escape(identifier)}?download"))
Client.get("#{entity_endpoint}?download")
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/siteleaf/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Siteleaf
VERSION = "2.1.0"
VERSION = "2.1.1"
end

0 comments on commit 5b9739c

Please sign in to comment.