[openstreetmap/openstreetmap-website] Deconvolute linkify logic (PR #6720)

Marwin Hochfelsner notifications at github.com
Wed Jan 21 10:50:57 UTC 2026


@hlfan commented on this pull request.



> @@ -87,18 +87,33 @@ def sanitize(text)
       Sanitize.clean(text, Sanitize::Config::OSM).html_safe
     end
 
-    def linkify(text, mode = :urls)
-      ERB::Util.html_escape(text)
-               .then { |html| expand_link_shorthands(html) }
-               .then { |html| expand_host_shorthands(html) }
-               .then { |html| auto_link(html, mode) }
-               .html_safe
+    def linkify(text, mode = :urls, hosts: true, paths: true)
+      link_attr = 'rel="nofollow noopener noreferrer" dir="auto"'
+      html = ERB::Util.html_escape(text)
+
+      html = expand_link_shorthands(html) if paths
+      html = expand_host_shorthands(html) if hosts

The input is still sanitized, and the Richtext.to_text function goes above leaving things as they are too.
@tomhughes might know more about why this exists.

Coming back to the `hosts` flag in `linkify`, I also think the symmetry makes even an underused option worthwhile here.

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

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


More information about the rails-dev mailing list