@hlfan 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 
https://github.com/openstreetmap/openstreetmap-website/issues/5780#issuecomment-2760413875
 and onward for the problem.

By canonical I mean the URL that is the target of the redirects which is on the 
`www.openstreetmap.org` domain. The path is still canonical on the shortened 
domains.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6518#discussion_r2519386751
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