3232 *
3333 * @throws HTTPException For invalid paths.
3434 * @throws InvalidArgumentException For invalid config.
35+ *
36+ * @deprecated No longer used.
3537 */
3638 function _get_uri (string $ relativePath = '' , ?App $ config = null , bool $ useConfig = false ): URI
3739 {
@@ -224,7 +226,11 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul
224226 $ routePath = $ request ->getPath ();
225227 $ currentURI = $ request ->getUri ();
226228
229+ $ url = $ request ->getUri ()->getBaseURL ();
230+
231+ $ config = config ('App ' );
227232 $ relativePath = $ routePath ;
233+
228234 // Append queries and fragments
229235 if ($ query = $ currentURI ->getQuery ()) {
230236 $ relativePath .= '? ' . $ query ;
@@ -233,7 +239,17 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul
233239 $ relativePath .= '# ' . $ fragment ;
234240 }
235241
236- $ uri = _get_uri ($ relativePath );
242+ // Check for an index page
243+ if ($ config ->indexPage !== '' ) {
244+ $ url .= $ config ->indexPage ;
245+
246+ // Check if we need a separator
247+ if ($ relativePath !== '' && $ relativePath [0 ] !== '/ ' && $ relativePath [0 ] !== '? ' ) {
248+ $ url .= '/ ' ;
249+ }
250+ }
251+
252+ $ uri = new URI ($ url . $ relativePath );
237253
238254 return $ returnObject ? $ uri : URI ::createURIString ($ uri ->getScheme (), $ uri ->getAuthority (), $ uri ->getPath ());
239255 }
0 commit comments