Browse Source

Fix Core\Router\validate()

If there is no route for GET and the response is METHOD_NOT_ALLOWED, then check the route for POST
Visman 4 years ago
parent
commit
9a064e3b89
1 changed files with 10 additions and 2 deletions
  1. 10 2
      app/Core/Router.php

+ 10 - 2
app/Core/Router.php

@@ -98,8 +98,16 @@ class Router
         if (
         if (
             \is_string($url)
             \is_string($url)
             && \parse_url($url, \PHP_URL_HOST) === $this->host
             && \parse_url($url, \PHP_URL_HOST) === $this->host
-            && ($route = $this->route('GET', \rawurldecode(\parse_url($url, \PHP_URL_PATH))))
-            && self::OK === $route[0]
+            && ($uri = \rawurldecode(\parse_url($url, \PHP_URL_PATH)))
+            && ($route = $this->route(self::GET, $uri))
+            && (
+                self::OK === $route[0]
+                || (
+                    self::METHOD_NOT_ALLOWED === $route[0]
+                    && ($route = $this->route(self::PST, $uri))
+                    && self::OK === $route[0]
+                )
+            )
         ) {
         ) {
             if (isset($route[3])) {
             if (isset($route[3])) {
                 return $this->link($route[3], $route[2]);
                 return $this->link($route[3], $route[2]);