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

Marwin Hochfelsner notifications at github.com
Mon Dec 15 03:54:37 UTC 2025


@hlfan requested changes 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>"

This should go through `Rinku.auto_link` as well to keep it DRY

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

Message ID: <openstreetmap/openstreetmap-website/pull/6616/review/3576277773 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251214/af5a81b2/attachment-0001.htm>


More information about the rails-dev mailing list