@hlfan commented on this pull request.


> +        shorten_host(normalised_url, rule.hosts, rule.host_replacement) do 
> |path|
+          path.sub(Regexp.new(rule.optional_path_prefix || ""), "")
+        end

Could we just pass `shorten_host` the whole rule and handle it there?

> @@ -133,9 +131,12 @@ def auto_link(text, mode)
     end
 
     def format_link_text(url)
-      url = shorten_host(url, Settings.linkify_hosts, 
Settings.linkify_hosts_replacement)
-      url = shorten_host(url, Settings.linkify_wiki_hosts, 
Settings.linkify_wiki_hosts_replacement) do |path|
-        path.sub(Regexp.new(Settings.linkify_wiki_optional_path_prefix || ""), 
"")
+      url = Array

Splitting the host and path related stuff made the expansion easier to read:

https://github.com/openstreetmap/openstreetmap-website/blob/c1dc08b5308b47ba5579fde79123f5588e4f2427/lib/rich_text.rb#L92-L93

Doing that here too instead of reassigning the URL could be an option.

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

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

Reply via email to