I’m totally new to Ruby, did some PHP (don’t blame me and some JS but I need to understand this simple function. It sanitizes links but I have some issues to understand the full functionality.
I have to enhance the function but don’t know how: I want to enhance links in User-Generated-Content with " rel=“nofollow ugc” " … there’s already this function but it gives me a hard time to understand it.
return unless str.present?
# Sanitize before we link
str = sanitize(str)
str.gsub!(Post.at_reply_regexp) do |match|
user = User.find_by_login(match[1…-1])
user ? (’@%s’ % [user.blog.verified_url, user.login]) : match
Thanks for your help.