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 {
9
9
10
10
// (A) RUN URL ROUTING ENGINE
11
11
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
13
23
// http://site.com/ > $this->path = "/"
14
24
// 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 );
16
26
if (substr ($ this ->path , 0 , strlen (HOST_BASE_PATH )) == HOST_BASE_PATH ) {
17
27
$ this ->path = substr ($ this ->path , strlen (HOST_BASE_PATH ));
18
28
}
You can’t perform that action at this time.
0 commit comments