[openstreetmap/openstreetmap-website] Add URL prettification for plain texts (PR #6518)
Tom Hughes
notifications at github.com
Sun Dec 7 12:44:38 UTC 2025
@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/3549249570 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251207/8519a4a8/attachment.htm>
More information about the rails-dev
mailing list