Skip to content

Commit

Permalink
Refactor Route.py to include a default option for route names
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Oct 16, 2024
1 parent 70b4537 commit 5271c3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/masonite/routes/Route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 2 additions & 0 deletions tests/routes/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5271c3c

Please sign in to comment.