@tomhughes commented on this pull request.
> + Regexp.new("(?<before>^|#{URL_UNSAFE_CHARS})#{pattern}",
> Regexp::IGNORECASE),
+ "\\k<before>#{expanded_path}"
I think you could use a lookbehind assertion here and then you wouldn't need to
capture the prefix and add it back, like this:
```suggestion
Regexp.new("(?<=^|#{URL_UNSAFE_CHARS})#{pattern}",
Regexp::IGNORECASE),
expanded_path
```
> +
> text.gsub(/(^|#{URL_UNSAFE_CHARS})\b#{Regexp.escape(replacement)}/) do
+ "#{Regexp.last_match(1)}#{Settings.server_protocol}://#{hosts[0]}"
Another candidate for an assertion?
```suggestion
text.gsub(/(?<=^|#{URL_UNSAFE_CHARS})\b#{Regexp.escape(replacement)}/) do
"#{Settings.server_protocol}://#{hosts[0]}"
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6518#pullrequestreview-3549249570
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