Permalink
Browse files

No need to unescape on ID lookups

  • Loading branch information...
1 parent 8dd6e8c commit aca69b07df47170c6ea1694c361d92ff87f51563 @ches ches committed Jun 27, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/rack/gridfs/endpoint/base.rb
View
8 lib/rack/gridfs/endpoint/base.rb
@@ -23,7 +23,6 @@ def call(env)
end
def key_for_path(path)
- path = CGI::unescape(path)
@mapper.respond_to?(:call) ? @mapper.call(path) : path
end
@@ -62,8 +61,11 @@ def response_for(file, request)
def find_file(id_or_path)
case @lookup.to_sym
- when :id then Mongo::Grid.new(db).get(BSON::ObjectId.from_string(id_or_path))
- when :path then Mongo::GridFileSystem.new(db).open(id_or_path, "r")
+ when :id
+ Mongo::Grid.new(db).get(BSON::ObjectId.from_string(id_or_path))
+ when :path
+ path = CGI::unescape(id_or_path)
+ Mongo::GridFileSystem.new(db).open(path, "r")
end
end

0 comments on commit aca69b0

Please sign in to comment.