Selaa lähdekoodia

Merge remote-tracking branch 'origin/master' into v2

shalvah 4 vuotta sitten
vanhempi
commit
ccb532cc99
2 muutettua tiedostoa jossa 8 lisäystä ja 8 poistoa
  1. 4 0
      CHANGELOG.md
  2. 4 8
      src/Tools/Utils.php

+ 4 - 0
CHANGELOG.md

@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project aims to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## 1.8.1 (Thursday, 17 September, 2020)
+### Fixes
+- Printing form data body parameters no longer throws an error with nested arrays or objects ()
+
 ## 1.8.0 (Tuesday, 15 September, 2020)
 - Lumen 8 support
 - Fixed Laravel 8 + legacy factories support

+ 4 - 8
src/Tools/Utils.php

@@ -59,18 +59,14 @@ class Utils
      */
     public static function replaceUrlParameterPlaceholdersWithValues(string $uri, array $urlParameters)
     {
-        $matches = preg_match_all('/{.+?}/i', $uri, $parameterPaths);
-        if (!$matches) {
+        if (empty($urlParameters)) {
             return $uri;
         }
 
-        foreach ($parameterPaths[0] as $parameterPath) {
-            $key = trim($parameterPath, '{?}');
-            if (isset($urlParameters[$key])) {
-                $example = $urlParameters[$key];
-                $uri = str_replace($parameterPath, $example, $uri);
-            }
+        foreach ($urlParameters as $parameterName => $example) {
+            $uri = preg_replace('#\{' . $parameterName . '[^/]*?}?}#', $example, $uri); // The second closing brace is present to account for regexes ending in a }
         }
+
         // Remove unbound optional parameters with nothing
         $uri = preg_replace('#{([^/]+\?)}#', '', $uri);
         // Replace any unbound non-optional parameters with '1'