diff app/models/paste.rb @ 464:f11862e58af4

Canonicalize 0-prefixed ids as well
author nanaya <me@nanaya.pro>
date Mon, 10 Dec 2018 02:38:45 +0900
parents b445318de858
children 02d043b1967d
line wrap: on
line diff
--- a/app/models/paste.rb	Mon Dec 10 02:35:08 2018 +0900
+++ b/app/models/paste.rb	Mon Dec 10 02:38:45 2018 +0900
@@ -15,9 +15,9 @@
   end
 
   def self.safe_find(raw_id)
-    /\A(?<id>[0-9]+)(?:-(?<secret>[0-9a-f]+))?\z/ =~ raw_id.to_s
+    /\A(?<id>[0-9]+)(?:-(?<secret>[0-9a-f]+))?\z/i =~ raw_id.to_s
 
-    find_by(:secret => secret, :id => id)
+    find_by(:secret => secret.try(:downcase), :id => id)
   end
 
   def self.graceful_create(params)