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(
80
80
$ query ,
81
81
$ fragment
82
82
) {
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 ;
84
86
$ this ->user = $ user ;
85
87
$ this ->pass = $ pass ;
86
88
$ this ->host = $ host ;
Original file line number Diff line number Diff line change @@ -181,4 +181,18 @@ public function testSchemeAlwaysConvertedToLowerCasePerRFC3986()
181
181
$ url = $ this ->parser ->parseUrl ($ spec );
182
182
$ this ->assertEquals ($ expected , $ url ->__toString ());
183
183
}
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
+ }
184
198
}
You can’t perform that action at this time.
0 commit comments