]> git.openstreetmap.org Git - rails.git/blobdiff - lib/short_link.rb
Update image_optim and disable cleanupIDs plugin
[rails.git] / lib / short_link.rb
index 44b9d719df39fd77477a5243a3d3f5f8bb885ea0..43d64041e6b7a765114f36ea4b7e302dd3ac392a 100644 (file)
@@ -8,7 +8,7 @@ module ShortLink
   # array of 64 chars to encode 6 bits. this is almost like base64 encoding, but
   # the symbolic chars are different, as base64's + and / aren't very
   # URL-friendly.
-  ARRAY = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['_', '~']
+  ARRAY = ("A".."Z").to_a + ("a".."z").to_a + ("0".."9").to_a + ["_", "~"]
 
   ##
   # Given a string encoding a location, returns the [lon, lat, z] tuple of that
@@ -22,7 +22,7 @@ module ShortLink
     # keep support for old shortlinks which use the @ character, now
     # replaced by the ~ character because twitter is horribly broken
     # and we can't have that.
-    str.gsub!("@", "~")
+    str.tr!("@", "~")
 
     str.each_char do |c|
       t = ARRAY.index c
@@ -55,7 +55,7 @@ module ShortLink
   # given a location and zoom, return a short string representing it.
   def self.encode(lon, lat, z)
     code = interleave_bits(((lon + 180.0) * 2**32 / 360.0).to_i,
-                           ((lat +  90.0) * 2**32 / 180.0).to_i)
+                           ((lat + 90.0) * 2**32 / 180.0).to_i)
     str = ""
     # add eight to the zoom level, which approximates an accuracy of
     # one pixel in a tile.