-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
withScheme weird results #16
Comments
@xobotyi you indeed did caught a bug (a regression from URI v5 😢 ) but it's not what you think 😄 TL;DR: Uri::createFromString('domain.com')->withScheme(''); Should throw as an URI scheme can not be the empty string. Only PSR-7 allow the empty string but there's a specific class for that in the repo (ie the Nevertheless the behaviour is expected because when you do $uri = Uri::createFromString('domain.com');
$uri->getHost(); // return null;
$uri->getPath(); //return 'domain.com' you endup with an URI which only has a path set and not it's host. To set up the host you should do the following instead $uri = Uri::createFromString('//domain.com');
$uri->getHost(); //return 'domain.com';
$uri->getPath(); //return '' |
Huh. |
yes there is <?php
$uri = Uri::createFromString('https://domain.com')->withScheme(null);
// or
$uri = Http::createFromString('https://domain.com')->withScheme(''); Depending on the class you are using |
Bug Report
(Fill in the relevant information below to help triage your issue.)
Summary
withScheme('')
should set make network-path reference, but it does invalid URI instead.IMO when scheme set to empty string it shoud remove the scheme specification making the URI Network-Path Reference. And null to remove the scheme segment at all.
Standalone code, or other way to reproduce the problem
Expected result
"//domain.com"
Actual result
":domain.com"
The text was updated successfully, but these errors were encountered: