DEV: Rename UriHelper.escape_uri to .normalized_encode

This is a much better description of its function. It performs idempotent normalization of a URL. If consumers truly need to `encode` a URL (including double-encoding of existing encoded entities), they can use the existing `.encode` method.
This commit is contained in:
David Taylor
2022-08-09 11:28:29 +01:00
parent f0a0252526
commit 3c81683955
9 changed files with 40 additions and 34 deletions

View File

@ -16,7 +16,7 @@ class EmbeddableHost < ActiveRecord::Base
def self.record_for_url(uri)
if uri.is_a?(String)
uri = begin
URI(UrlHelper.escape_uri(uri))
URI(UrlHelper.normalized_encode(uri))
rescue URI::Error, Addressable::URI::InvalidURIError
end
end
@ -50,7 +50,7 @@ class EmbeddableHost < ActiveRecord::Base
return true if url&.starts_with?(Discourse.base_url) && EmbeddableHost.exists?
uri = begin
URI(UrlHelper.escape_uri(url))
URI(UrlHelper.normalized_encode(url))
rescue URI::Error
end