[openstreetmap/openstreetmap-website] Simpliy linkify normalisation to use a single array of rules (PR #5862)
Marwin Hochfelsner
notifications at github.com
Fri Jan 9 00:36:49 UTC 2026
@hlfan requested changes on this pull request.
> + .reduce(url) do |normalised_url, rule|
+ shorten_host(normalised_url, rule.hosts, rule.host_replacement) do |path|
+ path.sub(Regexp.new(rule.optional_path_prefix || ""), "")
+ end
```suggestion
.reduce(url) { |url, rule| shorten_host(url, rule) }
```
```ruby
def shorten_host(url, rule)
%r{^(https?://([^/]*))(.*)$}.match(url) do |m|
scheme_host, host, path = m.captures
if rule.hosts&.include?(host)
path = path.sub(Regexp.new(rule.optional_path_prefix || ""), "")
if rule.host_replacement
"#{rule.host_replacement}#{path}"
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5862#pullrequestreview-3641879747
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5862/review/3641879747 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260108/d81c8040/attachment.htm>
More information about the rails-dev
mailing list