@@ -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,21 @@ def valid_label?(label)
124120 label . match? ( LETTERS_DIGITS_HYPHEN )
125121 end
126122
123+ def get_public_suffix_domain ( host )
124+ public_suffix_domain = PublicSuffix . parse ( host , list : CUSTOM_PSL , default_rule : nil )
125+ raise Twingly ::URL ::Error ::ParseError if public_suffix_domain . nil?
126+ raise Twingly ::URL ::Error ::ParseError if public_suffix_domain . sld . nil?
127+ public_suffix_domain
128+ end
129+
127130 private :new
128131 private :internal_parse
129132 private :clean_input
130133 private :strip_whitespace
131134 private :try_addressable_normalize
132135 private :valid_hostname?
133136 private :valid_label?
137+ private :get_public_suffix_domain
134138 end
135139
136140 def initialize ( addressable_uri , public_suffix_domain )
@@ -189,7 +193,8 @@ def normalized
189193 normalized_url . host = normalized_host
190194 normalized_url . path = normalized_path
191195
192- self . class . parse ( normalized_url )
196+ public_suffix_domain = self . class . send ( :get_public_suffix_domain , normalized_url . host )
197+ self . class . send ( :new , normalized_url , public_suffix_domain )
193198 end
194199
195200 def normalized_scheme
0 commit comments