@@ -73,11 +73,7 @@ def internal_parse(input)
7373 try_addressable_normalize ( addressable_uri )
7474
7575 host = addressable_uri . host
76- public_suffix_domain = PublicSuffix . parse ( host , list : CUSTOM_PSL ,
77- default_rule : nil )
78- raise Twingly ::URL ::Error ::ParseError if public_suffix_domain . nil?
79-
80- raise Twingly ::URL ::Error ::ParseError if public_suffix_domain . sld . nil?
76+ public_suffix_domain = get_public_suffix_domain ( addressable_uri . host )
8177
8278 new ( addressable_uri , public_suffix_domain )
8379 rescue *ERRORS_TO_EXTEND => error
@@ -124,13 +120,22 @@ def valid_label?(label)
124120 label . match? ( LETTERS_DIGITS_HYPHEN )
125121 end
126122
127- private :new
123+ def get_public_suffix_domain ( host )
124+ public_suffix_domain = PublicSuffix . parse ( host , list : CUSTOM_PSL ,
125+ default_rule : nil )
126+ raise Twingly ::URL ::Error ::ParseError if public_suffix_domain . nil?
127+ raise Twingly ::URL ::Error ::ParseError if public_suffix_domain . sld . nil?
128+ public_suffix_domain
129+ end
130+
131+ protected :new
128132 private :internal_parse
129133 private :clean_input
130134 private :strip_whitespace
131135 private :try_addressable_normalize
132136 private :valid_hostname?
133137 private :valid_label?
138+ private :get_public_suffix_domain
134139 end
135140
136141 def initialize ( addressable_uri , public_suffix_domain )
@@ -189,7 +194,8 @@ def normalized
189194 normalized_url . host = normalized_host
190195 normalized_url . path = normalized_path
191196
192- self . class . parse ( normalized_url )
197+ public_suffix_domain = self . class . send ( :get_public_suffix_domain , normalized_url . host )
198+ self . class . send ( :new , normalized_url , public_suffix_domain )
193199 end
194200
195201 def normalized_scheme
0 commit comments