File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,9 @@ public function __construct(
8080 $ query ,
8181 $ fragment
8282 ) {
83- $ this ->scheme = mb_strtolower ($ scheme , 'UTF-8 ' );
83+ // Ensure scheme is either a legit scheme or null, never an empty string.
84+ // @see https://github.com/jeremykendall/php-domain-parser/issues/53
85+ $ this ->scheme = mb_strtolower ($ scheme , 'UTF-8 ' ) ?: null ;
8486 $ this ->user = $ user ;
8587 $ this ->pass = $ pass ;
8688 $ this ->host = $ host ;
Original file line number Diff line number Diff line change @@ -181,4 +181,18 @@ public function testSchemeAlwaysConvertedToLowerCasePerRFC3986()
181181 $ url = $ this ->parser ->parseUrl ($ spec );
182182 $ this ->assertEquals ($ expected , $ url ->__toString ());
183183 }
184+
185+ /**
186+ * Scheme should return null when scheme is not provided.
187+ *
188+ * @group issue53
189+ *
190+ * @see https://github.com/jeremykendall/php-domain-parser/issues/53
191+ */
192+ public function testSchemeReturnsNullIfNotProvidedToParser ()
193+ {
194+ $ spec = 'google.com ' ;
195+ $ url = $ this ->parser ->parseUrl ($ spec );
196+ $ this ->assertNull ($ url ->getScheme ());
197+ }
184198}
You can’t perform that action at this time.
0 commit comments