[openstreetmap/openstreetmap-website] Fix issue #6614: Support spaces in @mentions using quotes (PR #6616)

Anshul Zilpe notifications at github.com
Mon Dec 15 07:24:53 UTC 2025


@aNsHuL5217 commented on this pull request.



> @@ -97,6 +98,16 @@ def linkify(text, mode = :urls)
 
     private
 
+    def linkify_users(text)
+      text.gsub(/(?<!\w)@(?:(?:"|["“”])(.+?)(?:"|["“”])|(\w+))/) do |match|
+        name = ::Regexp.last_match(1) || ::Regexp.last_match(2)
+        slug = ERB::Util.url_encode(name)
+        safe_match = match.sub("@", "@")
+
+        "<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/3576784276 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251214/70c1e8d4/attachment.htm>


More information about the rails-dev mailing list