OSDN Git Service

replace quotes to avoid unexpected behavior on regex
authorJefersson Nathan <admin@phpse.net>
Fri, 23 Dec 2016 14:48:16 +0000 (11:48 -0300)
committerJefersson Nathan <admin@phpse.net>
Fri, 23 Dec 2016 14:48:16 +0000 (11:48 -0300)
src/Router.php

index 11d44bf..e621ea4 100755 (executable)
@@ -121,7 +121,7 @@ class Router
 
             $params = array();
 
-            if (preg_match_all("/:([\w-%]+)/", $routes->getUrl(), $argument_keys)) {
+            if (preg_match_all('/:([\w-%]+)/', $routes->getUrl(), $argument_keys)) {
                 // grab array with matches
                 $argument_keys = $argument_keys[1];
 
@@ -170,14 +170,14 @@ class Router
         $url = $route->getUrl();
 
         // replace route url with given parameters
-        if ($params && preg_match_all("/:(\w+)/", $url, $param_keys)) {
+        if ($params && preg_match_all('/:(\w+)/', $url, $param_keys)) {
             // grab array with matches
             $param_keys = $param_keys[1];
 
             // loop trough parameter names, store matching value in $params array
             foreach ($param_keys as $key) {
                 if (isset($params[$key])) {
-                    $url = preg_replace("/:(\w+)/", $params[$key], $url, 1);
+                    $url = preg_replace('/:(\w+)/', $params[$key], $url, 1);
                 }
             }
         }