@aNsHuL5217 commented on this pull request.


> @@ -97,6 +98,16 @@ def linkify(text, mode = :urls)
 
     private
 
+    def linkify_users(text)
+      text.gsub(/(?<!\w)@(?:(?:&quot;|["“”])(.+?)(?:&quot;|["“”])|(\w+))/) do 
|match|
+        name = ::Regexp.last_match(1) || ::Regexp.last_match(2)
+        slug = ERB::Util.url_encode(name)
+        safe_match = match.sub("@", "&#64;")
+
+        "<a href=\"/user/#{slug}\" rel=\"nofollow noopener 
noreferrer\">#{safe_match}</a>"

Thanks for pointing that out! While Rinku doesn’t provide a builder for 
arbitrary tags, I noticed I was duplicating link attributes and had also missed 
dir="auto". I’ve refactored those into a shared LINK_ATTRIBUTES constant used 
by both linkify_users and auto_link to keep things DRY and consistent.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6616#discussion_r2618273589
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/6616/review/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to