File tree Expand file tree Collapse file tree 2 files changed +22
-15
lines changed
Expand file tree Collapse file tree 2 files changed +22
-15
lines changed Original file line number Diff line number Diff line change 2020
2121class Uri implements UriInterface{
2222
23- protected const DEFAULT_PORTS = [
24- 'http ' => 80 ,
25- 'https ' => 443 ,
26- 'ftp ' => 21 ,
27- 'gopher ' => 70 ,
28- 'nntp ' => 119 ,
29- 'news ' => 119 ,
30- 'telnet ' => 23 ,
31- 'tn3270 ' => 23 ,
32- 'imap ' => 143 ,
33- 'pop ' => 110 ,
34- 'ldap ' => 389 ,
35- ];
36-
3723 protected string $ scheme = '' ;
3824
3925 protected string $ user = '' ;
@@ -498,7 +484,7 @@ function(array $match):string{
498484 */
499485 protected function removeDefaultPort ():void {
500486
501- if ($ this -> port !== null && ( isset ( $ this :: DEFAULT_PORTS [ $ this -> scheme ]) && $ this -> port === $ this :: DEFAULT_PORTS [ $ this -> scheme ] )){
487+ if (uriIsDefaultPort ( $ this )){
502488 $ this ->port = null ;
503489 }
504490
Original file line number Diff line number Diff line change @@ -500,6 +500,27 @@ function decompress_content(MessageInterface $message):string{
500500
501501}
502502
503+ const URI_DEFAULT_PORTS = [
504+ 'http ' => 80 ,
505+ 'https ' => 443 ,
506+ 'ftp ' => 21 ,
507+ 'gopher ' => 70 ,
508+ 'nntp ' => 119 ,
509+ 'news ' => 119 ,
510+ 'telnet ' => 23 ,
511+ 'tn3270 ' => 23 ,
512+ 'imap ' => 143 ,
513+ 'pop ' => 110 ,
514+ 'ldap ' => 389 ,
515+ ];
516+
517+ function uriIsDefaultPort (UriInterface $ uri ):bool {
518+ $ port = $ uri ->getPort ();
519+ $ scheme = $ uri ->getScheme ();
520+
521+ return $ port === null || (isset (URI_DEFAULT_PORTS [$ scheme ]) && $ port === URI_DEFAULT_PORTS [$ scheme ]);
522+ }
523+
503524/**
504525 * Whether the URI is absolute, i.e. it has a scheme.
505526 *
You can’t perform that action at this time.
0 commit comments