@tomhughes commented on this pull request.


>        end.html_safe
     end
 
     private
 
+    def expand_link_shorthands(text)
+      linkify_detection_rules = Array.wrap(Settings.linkify&.detection_rules)
+      linkify_detection_rules.each do |rule|
+        next unless rule.path_template && rule.patterns.is_a?(Array)
+
+        rule.patterns.each do |pattern|
+          expanded_path = "#{Settings.server_protocol}://#{rule.host || 
Settings.server_url}/#{rule.path_template}"
+          
text.gsub!(Regexp.new("(?<before>\\s|^|>)#{pattern}(?<after>\\s|$|<)", 
Regexp::IGNORECASE), "\\k<before>#{expanded_path}\\k<after>")
+        end
+      end
+      [[Settings.linkify_hosts, Settings.linkify_hosts_replacement], 
[Settings.linkify_wiki_hosts, Settings.linkify_wiki_hosts_replacement]].each do 
|hosts, replacement|
+        text.gsub!(/(\s)#{Regexp.escape(replacement)}/, 
"\\1#{Settings.server_protocol}://#{hosts[0]}") if replacement && hosts&.any?
+      end

> See [#5780 
> (comment)](https://github.com/openstreetmap/openstreetmap-website/issues/5780#issuecomment-2760413875)
>  and onward for the problem.

That explains (or at least claims) that copy paste breaks something but I don't 
see any analysis there of how/why it breaks or why this code would fix the 
problem?

Basically I'm reviewing this again and I'm staring at the second commit and I 
can't see anything technically wrong with it but I still have no understanding 
of why it's needed.

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

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

Reply via email to