@@ -103,15 +103,15 @@ private function parseRequestURI(): string
103103 // parse out the query string and path.
104104 $ parts = parse_url ('http://dummy ' . $ this ->server ['REQUEST_URI ' ]);
105105 $ query = $ parts ['query ' ] ?? '' ;
106- $ uri = $ parts ['path ' ] ?? '' ;
106+ $ path = $ parts ['path ' ] ?? '' ;
107107
108108 // Strip the SCRIPT_NAME path from the URI
109109 if (
110- $ uri !== '' && isset ($ this ->server ['SCRIPT_NAME ' ][0 ])
110+ $ path !== '' && isset ($ this ->server ['SCRIPT_NAME ' ][0 ])
111111 && pathinfo ($ this ->server ['SCRIPT_NAME ' ], PATHINFO_EXTENSION ) === 'php '
112112 ) {
113113 // Compare each segment, dropping them until there is no match
114- $ segments = $ keep = explode ('/ ' , $ uri );
114+ $ segments = $ keep = explode ('/ ' , $ path );
115115
116116 foreach (explode ('/ ' , $ this ->server ['SCRIPT_NAME ' ]) as $ i => $ segment ) {
117117 // If these segments are not the same then we're done
@@ -122,25 +122,26 @@ private function parseRequestURI(): string
122122 array_shift ($ keep );
123123 }
124124
125- $ uri = implode ('/ ' , $ keep );
125+ $ path = implode ('/ ' , $ keep );
126126 }
127127
128128 // This section ensures that even on servers that require the URI to
129129 // contain the query string (Nginx) a correct URI is found, and also
130130 // fixes the QUERY_STRING Server var and $_GET array.
131- if (trim ($ uri , '/ ' ) === '' && strncmp ($ query , '/ ' , 1 ) === 0 ) {
132- $ query = explode ('? ' , $ query , 2 );
133- $ uri = $ query [0 ];
131+ if (trim ($ path , '/ ' ) === '' && strncmp ($ query , '/ ' , 1 ) === 0 ) {
132+ $ parts = explode ('? ' , $ query , 2 );
133+ $ path = $ parts [0 ];
134+ $ newQuery = $ query [1 ] ?? '' ;
134135
135- $ this ->server ['QUERY_STRING ' ] = $ query [ 1 ] ?? '' ;
136+ $ this ->server ['QUERY_STRING ' ] = $ newQuery ;
136137 } else {
137138 $ this ->server ['QUERY_STRING ' ] = $ query ;
138139 }
139140
140- // Update our globals for values likely to have been changed
141+ // Update our global GET for values likely to have been changed
141142 parse_str ($ this ->server ['QUERY_STRING ' ], $ this ->get );
142143
143- return URI ::removeDotSegments ($ uri );
144+ return URI ::removeDotSegments ($ path );
144145 }
145146
146147 /**
@@ -152,23 +153,26 @@ private function parseRequestURI(): string
152153 */
153154 private function parseQueryString (): string
154155 {
155- $ uri = $ this ->server ['QUERY_STRING ' ] ?? @getenv ('QUERY_STRING ' );
156+ $ query = $ this ->server ['QUERY_STRING ' ] ?? @getenv ('QUERY_STRING ' );
156157
157- if (trim ($ uri , '/ ' ) === '' ) {
158+ if (trim ($ query , '/ ' ) === '' ) {
158159 return '/ ' ;
159160 }
160161
161- if (strncmp ($ uri , '/ ' , 1 ) === 0 ) {
162- $ uri = explode ('? ' , $ uri , 2 );
163- $ uri = $ uri [0 ];
162+ if (strncmp ($ query , '/ ' , 1 ) === 0 ) {
163+ $ parts = explode ('? ' , $ query , 2 );
164+ $ path = $ parts [0 ];
165+ $ newQuery = $ parts [1 ] ?? '' ;
164166
165- $ this ->server ['QUERY_STRING ' ] = $ uri [1 ] ?? '' ;
167+ $ this ->server ['QUERY_STRING ' ] = $ newQuery ;
168+ } else {
169+ $ path = $ query ;
166170 }
167171
168- // Update our globals for values likely to have been changed
172+ // Update our global GET for values likely to have been changed
169173 parse_str ($ this ->server ['QUERY_STRING ' ], $ this ->get );
170174
171- return URI ::removeDotSegments ($ uri );
175+ return URI ::removeDotSegments ($ path );
172176 }
173177
174178 /**
0 commit comments