From 5271c3c05c917816d97c14453b7cce47d8d88c4f Mon Sep 17 00:00:00 2001 From: Joe Mancuso Date: Wed, 16 Oct 2024 16:29:04 -0400 Subject: [PATCH] Refactor Route.py to include a default option for route names --- src/masonite/routes/Route.py | 2 +- tests/routes/test_routes.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/masonite/routes/Route.py b/src/masonite/routes/Route.py index 5ee2bdb1..252727d8 100644 --- a/src/masonite/routes/Route.py +++ b/src/masonite/routes/Route.py @@ -157,7 +157,7 @@ def group(self, *routes, **options): route.compile_route_to_regex() if options.get("name"): - route._name = options.get("name") + route._name + route._name = options.get("name", "") + (route._name or "") if options.get("domain"): route.domain(options.get("domain")) diff --git a/tests/routes/test_routes.py b/tests/routes/test_routes.py index 2b6bd3d7..10fae589 100644 --- a/tests/routes/test_routes.py +++ b/tests/routes/test_routes.py @@ -132,12 +132,14 @@ def test_group_naming(self): Route.group( Route.get("/group", "WelcomeController@show").name(".index"), Route.post("/login", "WelcomeController@show").name(".index"), + Route.post("/login", "WelcomeController@show"), prefix="/testing", name="dashboard", ) ) route = router.find_by_name("dashboard.index") + route = router.find_by_name("dashboard") self.assertTrue(route) def test_compile_year(self):