@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/[email protected]>_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev