File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,20 @@ class Route extends Core {
99
1010 // (A) RUN URL ROUTING ENGINE
1111 function run () : void {
12- // (A1) CLEAN CURRENT URL PATH
12+ // (A1) GET URL PATH SEGMENT
13+ $ this ->path = parse_url ($ _SERVER ["REQUEST_URI " ], PHP_URL_PATH );
14+
15+ // (A2) SPECIAL CASE
16+ // e.g. http://site.com//, http://site.com//XYZ
17+ if ($ this ->path == "" ) {
18+ $ this ->load ("PAGE-404.php " , 404 );
19+ exit ();
20+ }
21+
22+ // (A3) CLEAN CURRENT URL PATH
1323 // http://site.com/ > $this->path = "/"
1424 // http://site.com/hello/world/ > $this->path = "hello/world/"
15- $ this ->path = parse_url ( $ _SERVER [ " REQUEST_URI " ], PHP_URL_PATH );
25+ $ this ->path = preg_replace ( " ~/{2,}~ " , " / " , $ this -> path );
1626 if (substr ($ this ->path , 0 , strlen (HOST_BASE_PATH )) == HOST_BASE_PATH ) {
1727 $ this ->path = substr ($ this ->path , strlen (HOST_BASE_PATH ));
1828 }
You can’t perform that action at this time.
0 commit comments