diff --git a/src/Http/Regex.php b/src/Http/Regex.php index c99502bc..4d5cf79b 100644 --- a/src/Http/Regex.php +++ b/src/Http/Regex.php @@ -155,7 +155,7 @@ public function assemble(array $params = [], array $options = []) $spec = '%' . $key . '%'; if (strpos($url, $spec) !== false) { - $url = str_replace($spec, rawurlencode($value), $url); + $url = str_replace($spec, rawurlencode((string) $value), $url); $this->assembledParams[] = $key; } diff --git a/test/Http/RegexTest.php b/test/Http/RegexTest.php index 3bc6daa1..360196b3 100644 --- a/test/Http/RegexTest.php +++ b/test/Http/RegexTest.php @@ -64,6 +64,12 @@ public static function routeProvider() null, ['bar' => 'bar', 'baz' => 'baz'] ], + 'params-contain-non-string-scalar-values' => [ + new Regex('/id/(?\d+)/scale/(?\d+\.\d+)', '/id/%id%/scale/%scale%'), + '/id/42/scale/4.2', + null, + ['id' => 42, 'scale' => 4.2] + ], ]; }