Properly migrate users with usernames like "." or "..".
This commit is contained in:
parent
c0116926c7
commit
fac1f83fd5
|
@ -66,9 +66,13 @@ class Namespace < ActiveRecord::Base
|
||||||
path.gsub!(/\.+\z/, "")
|
path.gsub!(/\.+\z/, "")
|
||||||
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
|
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
|
||||||
|
|
||||||
|
# Users with the great usernames of "." or ".." would end up with a blank username.
|
||||||
|
# Work around that by setting their username to "blank", followed by a counter.
|
||||||
|
path = "blank" if path.blank?
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
base = path
|
base = path
|
||||||
while Namespace.by_path(path).present?
|
while Namespace.find_by_path_or_name(path)
|
||||||
counter += 1
|
counter += 1
|
||||||
path = "#{base}#{counter}"
|
path = "#{base}#{counter}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,10 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
|
||||||
path.gsub!(/\.+\z/, "")
|
path.gsub!(/\.+\z/, "")
|
||||||
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
|
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "")
|
||||||
|
|
||||||
|
# Users with the great usernames of "." or ".." would end up with a blank username.
|
||||||
|
# Work around that by setting their username to "blank", followed by a counter.
|
||||||
|
path = "blank" if path.blank?
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
base = path
|
base = path
|
||||||
while Namespace.find_by_path_or_name(path)
|
while Namespace.find_by_path_or_name(path)
|
||||||
|
|
Loading…
Reference in New Issue