projects
/
rails.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'osmlab/iD-1.6.0'
[rails.git]
/
lib
/
short_link.rb
diff --git
a/lib/short_link.rb
b/lib/short_link.rb
index b91d7e569dddc57d12e3b3fe02d11df7aea10e82..045883d57b5c45fb2435aa6e2411ffe1b7d58ce8 100644
(file)
--- a/
lib/short_link.rb
+++ b/
lib/short_link.rb
@@
-9,7
+9,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 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
##
# Given a string encoding a location, returns the [lon, lat, z] tuple of that
@@
-20,6
+20,11
@@
module ShortLink
z = 0
z_offset = 0
z = 0
z_offset = 0
+ # 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.each_char do |c|
t = ARRAY.index c
if t.nil?
str.each_char do |c|
t = ARRAY.index c
if t.nil?