File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -260,20 +260,24 @@ public function die($data, int $code = 500)
260260 * This method prepares this response to return an HTTP Redirect response
261261 * to the HTTP client.
262262 *
263- * @param string $url The redirect destination
263+ * @param string|array $url The redirect destination
264264 * @param int $status The redirect HTTP status code
265265 */
266- public function redirect (string $ url , int $ status = 302 )
266+ public function redirect ($ url , int $ status = 302 )
267267 {
268- if (class_exists ('Leaf\Eien\Server ' ) && PHP_SAPI === 'cli ' ) {
269- \Leaf \Config::set ('response.redirect ' , [$ url , $ status ]);
270- return ;
268+ if (is_array ($ url )) {
269+ $ url = app ()->route ($ url [0 ]);
271270 }
272271
273272 if (class_exists ('Leaf\App ' )) {
274273 $ url = str_replace ('// ' , '/ ' , app ()->getBasePath () . $ url );
275274 }
276275
276+ if (class_exists ('Leaf\Eien\Server ' ) && PHP_SAPI === 'cli ' ) {
277+ \Leaf \Config::set ('response.redirect ' , [$ url , $ status ]);
278+ return ;
279+ }
280+
277281 Headers::status ($ status );
278282 Headers::set ('Location ' , $ url , true , $ status );
279283 }
You can’t perform that action at this time.
0 commit comments