handle nil unsafe_uri in app conttroller function

This commit is contained in:
Devin Howard 2015-12-16 21:05:18 +08:00
parent 235d4f6c24
commit 6148f55e1c

View file

@ -60,7 +60,7 @@ private
def get_invite_link
unsafe_uri = request.env["REQUEST_URI"]
valid_url = /^https?:\/\/([\w\.-]+)(:\d{1,5})?\/?$/
safe_uri = (unsafe_uri.match(valid_url)) ? unsafe_uri : "http://metamaps.cc/"
safe_uri = unsafe_uri.try(:match, valid_url) ? unsafe_uri : "http://metamaps.cc/"
@invite_link = "#{safe_uri}join" + (current_user ? "?code=#{current_user.code}" : "")
end
end