Welcome Guest, Not a member yet? Register   Sign In
Please explain the router code.
#4

(This post was last modified: 05-16-2022, 09:11 PM by kenjis.)

From the time of the first PR, it looks the test passes without it.

Code:
--- a/system/Router/Router.php
+++ b/system/Router/Router.php
@@ -398,9 +398,9 @@ class Router implements RouterInterface
                    // ex: $routes->resource('Admin/Admins');
                    if (strpos($val, '$') !== false && strpos($key, '(') !== false && strpos($key, '/') !== false)
                    {
-                      $replacekey = str_replace('/(.*)', '', $key);
+//                    $replacekey = str_replace('/(.*)', '', $key);
                        $val = preg_replace('#^'.$key.'$#', $val, $uri);
-                      $val = str_replace($replacekey, str_replace("/", "\\",$replacekey), $val);
+//                    $val = str_replace($replacekey, str_replace("/", "\\",$replacekey), $val);
                    }
                    elseif (strpos($val, '$') !== false && strpos($key, '(') !== false)
                    {

(05-16-2022, 08:55 PM)iRedds Wrote: Perhaps some separate logic was planned here.
But I don't see the point in the first and second line.

That is, the condition can be reduced to a single preg_replace() call.

Agreed.
We can remove the if statement.
Reply


Messages In This Thread
Please explain the router code. - by iRedds - 05-15-2022, 10:00 PM
RE: Please explain the router code. - by kenjis - 05-16-2022, 08:33 PM
RE: Please explain the router code. - by iRedds - 05-16-2022, 08:55 PM
RE: Please explain the router code. - by kenjis - 05-16-2022, 09:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB