FIX: Invalid URLs could raise unwanted exceptions (PR #10762)

Upload.secure_media_url? raised an exceptions when the URL was invalid, which was a issue in some situations where secure media URLs must be removed.

For example, sending digests used PrettyText.strip_secure_media, which used Upload.secure_media_url? to replace secure media with placeholders. If the URL was invalid, then an exception would be raised and left unhandled.

GitHub

So it’s UrlHelper.rails_route_from_url who’s throwing this exception? Would it make more sense to have it handle it and return nil when the URL is invalid instead?

Sam asked me to get this merge and I fixed your comment @ZogStriP but it pushed to a different branch, so I just opened a new PR https://github.com/discourse/discourse/pull/10782