@@ -132,24 +132,24 @@ public function __construct($httpStringRequest = null)
132
132
133
133
$ this ->domain = new Domain ($ httpStringRequest );
134
134
135
- if (isset ($ parseUrl [ 'path ' ])) {
136
- $ xRequest = explode ('/ ' , $ parseUrl [ 'path ' ]);
135
+ if (isset ($ parseUrl ['path ' ])) {
136
+ $ xRequest = explode ('/ ' , $ parseUrl ['path ' ]);
137
137
$ this ->path = implode ('/ ' , array_slice ($ xRequest , 1 ));
138
138
}
139
139
140
140
if (strpos ($ this ->path , '.php ' ) !== false ) {
141
141
$ xPath = explode ('.php ' , $ this ->path );
142
- $ xPath = explode ('/ ' , trim ($ xPath [ 0 ], '/ ' ));
142
+ $ xPath = explode ('/ ' , trim ($ xPath [0 ], '/ ' ));
143
143
array_pop ($ xPath );
144
144
145
145
$ this ->path = empty ($ xPath ) ? null : implode ('/ ' , $ xPath );
146
146
}
147
147
148
- $ this ->query = isset ($ parseUrl [ 'query ' ]) ? $ parseUrl [ 'query ' ] : null ;
149
- $ this ->username = isset ($ parseUrl [ 'user ' ]) ? $ parseUrl [ 'user ' ] : null ;
150
- $ this ->password = isset ($ parseUrl [ 'pass ' ]) ? $ parseUrl [ 'pass ' ] : null ;
151
- $ this ->port = isset ($ parseUrl [ 'port ' ]) ? $ parseUrl [ 'port ' ] : 80 ;
152
- $ this ->fragment = isset ($ parseUrl [ 'fragment ' ]) ? $ parseUrl [ 'fragment ' ] : null ;
148
+ $ this ->query = isset ($ parseUrl ['query ' ]) ? $ parseUrl ['query ' ] : null ;
149
+ $ this ->username = isset ($ parseUrl ['user ' ]) ? $ parseUrl ['user ' ] : null ;
150
+ $ this ->password = isset ($ parseUrl ['pass ' ]) ? $ parseUrl ['pass ' ] : null ;
151
+ $ this ->port = isset ($ parseUrl ['port ' ]) ? $ parseUrl ['port ' ] : 80 ;
152
+ $ this ->fragment = isset ($ parseUrl ['fragment ' ]) ? $ parseUrl ['fragment ' ] : null ;
153
153
154
154
$ this ->segments = new Segments ($ this ->path );
155
155
} else {
@@ -159,47 +159,41 @@ public function __construct($httpStringRequest = null)
159
159
/**
160
160
* Define Uri Attribute
161
161
*/
162
- if (strpos ($ _SERVER [ 'PHP_SELF ' ], '/@ ' ) !== false ) {
163
- $ xPhpSelf = explode ('/@ ' , $ _SERVER [ 'PHP_SELF ' ]);
162
+ if (strpos ($ _SERVER ['PHP_SELF ' ], '/@ ' ) !== false ) {
163
+ $ xPhpSelf = explode ('/@ ' , $ _SERVER ['PHP_SELF ' ]);
164
164
165
- $ this ->attribute = '@ ' . $ xPhpSelf [ 1 ];
165
+ $ this ->attribute = '@ ' . $ xPhpSelf [1 ];
166
166
167
167
if (strpos ($ this ->attribute , '/ ' ) !== false ) {
168
168
$ xAttribute = explode ('/ ' , $ this ->attribute );
169
169
170
- $ this ->attribute = $ xAttribute [ 0 ];
170
+ $ this ->attribute = $ xAttribute [0 ];
171
171
}
172
172
}
173
173
174
174
/**
175
175
* Define Uri User and Password
176
176
*/
177
- if (preg_match ("/[a-zA-Z0-9]+[@][a-zA-Z0-9]+/ " , $ _SERVER [ 'PHP_SELF ' ], $ usernamePassword )) {
178
- $ xUsernamePassword = explode ('@ ' , $ usernamePassword [ 0 ]);
179
- $ this ->username = $ xUsernamePassword [ 0 ];
180
- $ this ->password = $ xUsernamePassword [ 1 ];
177
+ if (preg_match ("/[a-zA-Z0-9]+[@][a-zA-Z0-9]+/ " , $ _SERVER ['PHP_SELF ' ], $ usernamePassword )) {
178
+ $ xUsernamePassword = explode ('@ ' , $ usernamePassword [0 ]);
179
+ $ this ->username = $ xUsernamePassword [0 ];
180
+ $ this ->password = $ xUsernamePassword [1 ];
181
181
}
182
182
183
183
/**
184
184
* Define Uri Path
185
185
*/
186
- $ xPath = explode ('.php ' , $ _SERVER [ 'PHP_SELF ' ]);
187
- $ xPath = explode ('/ ' , trim ($ xPath [ 0 ], '/ ' ));
188
- array_pop ($ xPath );
189
-
190
- if (class_exists ('O2System\Framework ' , false )) {
191
- if (!empty ($ xPath )) {
192
- $ app = studlycase ($ xPath [0 ]);
193
- if (is_file (PATH_APP . $ app . DIRECTORY_SEPARATOR . 'app.json ' )) {
194
- unset($ xPath [0 ]);
195
- }
186
+ if (!is_file (input ()->server ('DOCUMENT_ROOT ' ) . input ()->server ('PHP_SELF ' ))) {
187
+ $ this ->path = null ;
188
+ } else {
189
+ $ this ->path = input ()->server ('PHP_SELF ' );
190
+
191
+ if ($ this ->path === '/index.php ' ) {
192
+ $ this ->path = null ;
196
193
}
197
194
}
198
195
199
- $ this ->path = empty ($ xPath ) ? null : implode ('/ ' , $ xPath ) . '/ ' ;
200
-
201
- $ this ->query = isset ($ _SERVER [ 'QUERY_STRING ' ]) ? $ _SERVER [ 'QUERY_STRING ' ] : null ;
202
-
196
+ $ this ->query = isset ($ _SERVER ['QUERY_STRING ' ]) ? $ _SERVER ['QUERY_STRING ' ] : null ;
203
197
}
204
198
}
205
199
@@ -244,7 +238,7 @@ public function withSegments(Segments $segments)
244
238
*/
245
239
public function addSegments ($ segments )
246
240
{
247
- if ( ! $ segments instanceof Segments) {
241
+ if (! $ segments instanceof Segments) {
248
242
$ segments = new Segments ($ segments );
249
243
}
250
244
@@ -310,11 +304,11 @@ public function getAuthority()
310
304
311
305
$ authority = $ this ->getHost ();
312
306
313
- if ( ! empty ($ this ->getUserInfo ())) {
307
+ if (! empty ($ this ->getUserInfo ())) {
314
308
$ authority = $ this ->getUserInfo () . '@ ' . $ authority ;
315
309
}
316
310
317
- if ( ! empty ($ this ->getPort ())) {
311
+ if (! empty ($ this ->getPort ())) {
318
312
if ($ this ->getPort () != 80 ) {
319
313
$ authority .= ': ' . $ this ->getPort ();
320
314
}
@@ -346,7 +340,7 @@ public function getUserInfo()
346
340
{
347
341
$ userInfo = $ this ->username ;
348
342
349
- if ( ! empty ($ this ->password )) {
343
+ if (! empty ($ this ->password )) {
350
344
$ userInfo .= ': ' . $ this ->password ;
351
345
}
352
346
@@ -609,7 +603,7 @@ public function withScheme($scheme)
609
603
* user; an empty string for the user is equivalent to removing user
610
604
* information.
611
605
*
612
- * @param string $user The user name to use for authority.
606
+ * @param string $user The user name to use for authority.
613
607
* @param null|string $password The password associated with $user.
614
608
*
615
609
* @return static|\O2System\Kernel\Http\Message\Uri A new instance with the specified user information.
@@ -773,15 +767,16 @@ public function addQuery($query)
773
767
774
768
parse_str ($ query , $ newQuery );
775
769
776
- if ( ! empty ($ uri ->query )) {
770
+ if (! empty ($ uri ->query )) {
777
771
parse_str ($ uri ->query , $ oldQuery );
778
772
$ query = array_merge ($ oldQuery , $ newQuery );
779
773
} else {
780
774
$ query = $ newQuery ;
781
775
}
782
776
783
777
if (is_array ($ query )) {
784
- $ uri ->query = is_array ($ query ) ? http_build_query ($ query , PHP_QUERY_RFC3986 , '& ' , PHP_QUERY_RFC3986 ) : $ query ;
778
+ $ uri ->query = is_array ($ query ) ? http_build_query ($ query , PHP_QUERY_RFC3986 , '& ' ,
779
+ PHP_QUERY_RFC3986 ) : $ query ;
785
780
}
786
781
787
782
return $ uri ;
@@ -907,7 +902,7 @@ public function __toString()
907
902
if ($ uriPath !== '/ ' &&
908
903
substr ($ uriPath , strlen ($ uriPath ) - 1 ) !== '/ ' &&
909
904
$ this ->suffix !== '' && $ this ->suffix !== '. ' &&
910
- ( ! is_cli () && $ uriPath . '/ ' !== $ _SERVER [ 'REQUEST_URI ' ]) &&
905
+ (! is_cli () && $ uriPath . '/ ' !== $ _SERVER ['REQUEST_URI ' ]) &&
911
906
pathinfo ($ uriPath , PATHINFO_EXTENSION ) === '' &&
912
907
strpos ($ uriPath , '# ' ) === false &&
913
908
empty ($ this ->query )
@@ -927,6 +922,8 @@ public function __toString()
927
922
? ''
928
923
: $ this ->fragment ;
929
924
925
+ $ uriString = str_replace (['https://. ' , 'http://. ' ], ['https:// ' , 'http:// ' ], $ uriString );
926
+
930
927
return $ uriString ;
931
928
}
932
929
}
0 commit comments