Skip to content

Commit 5271c3c

Browse files
committed
Refactor Route.py to include a default option for route names
1 parent 70b4537 commit 5271c3c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/masonite/routes/Route.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def group(self, *routes, **options):
157157
route.compile_route_to_regex()
158158

159159
if options.get("name"):
160-
route._name = options.get("name") + route._name
160+
route._name = options.get("name", "") + (route._name or "")
161161

162162
if options.get("domain"):
163163
route.domain(options.get("domain"))

tests/routes/test_routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,14 @@ def test_group_naming(self):
132132
Route.group(
133133
Route.get("/group", "WelcomeController@show").name(".index"),
134134
Route.post("/login", "WelcomeController@show").name(".index"),
135+
Route.post("/login", "WelcomeController@show"),
135136
prefix="/testing",
136137
name="dashboard",
137138
)
138139
)
139140

140141
route = router.find_by_name("dashboard.index")
142+
route = router.find_by_name("dashboard")
141143
self.assertTrue(route)
142144

143145
def test_compile_year(self):

0 commit comments

Comments
 (0)