Module: Wayfarer::URI::Normalization
Overview
HTTP(S) URL normalization.
Constant Summary collapse
- InvalidURIError =
Class.new(StandardError)
- RelativeURIError =
Raised when URI is relative.
Class.new(InvalidURIError)
- NoHypertextError =
Raised when URI scheme is not hypertext.
Class.new(InvalidURIError)
- NoHostError =
Raised when URI has no host.
Class.new(InvalidURIError)
Instance Method Summary collapse
-
#canonical!(uri) ⇒ Addressable::URI
Normalizes
uri
in-place.
Instance Method Details
#canonical!(uri) ⇒ Addressable::URI
Normalizes uri
in-place.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wayfarer/uri/normalization.rb', line 24 def canonical!(uri) had_no_path = uri.path.blank? uri.normalize! validate_uri!(uri) normalize_host!(uri) if remove_www? if remove_trailing_slash? normalize_path!(uri) root_path!(uri) end remove_fragment!(uri) if remove_fragment? normalize_query_params!(uri) root_path!(uri) if had_no_path && uri.query.nil? uri end |