@@ -167,6 +167,53 @@ final class RouterTests: XCTestCase {
167167        // Could update the router to automatically add "/" if URI strings are missing them,
168168        // automatically add/remove trailing "/", etc.
169169    } 
170+ 
171+     func  testGroupedPathPrefix( )  throws  { 
172+         self . app
173+             . grouped ( " group " )  {  app in 
174+                 app
175+                     . register ( . get1) 
176+                     . register ( . get2) 
177+                     . grouped ( " nested " )  {  app in 
178+                         app. register ( . post1) 
179+                     } 
180+                     . register ( . post2) 
181+             } 
182+             . register ( . get3) 
183+ 
184+         XCTAssertEqual ( try   self . app. request ( TestRequest ( 
185+             method:  . GET, 
186+             path:  " /group \( TestRequest . get1. path) " , 
187+             response:  TestRequest . get1. path
188+         ) ) ,  TestRequest . get1. response) 
189+ 
190+         XCTAssertEqual ( try   self . app. request ( TestRequest ( 
191+             method:  . GET, 
192+             path:  " /group \( TestRequest . get2. path) " , 
193+             response:  TestRequest . get2. path
194+         ) ) ,  TestRequest . get2. response) 
195+ 
196+         XCTAssertEqual ( try   self . app. request ( TestRequest ( 
197+             method:  . POST, 
198+             path:  " /group/nested \( TestRequest . post1. path) " , 
199+             response:  TestRequest . post1. path
200+         ) ) ,  TestRequest . post1. response) 
201+ 
202+         XCTAssertEqual ( try   self . app. request ( TestRequest ( 
203+             method:  . POST, 
204+             path:  " /group \( TestRequest . post2. path) " , 
205+             response:  TestRequest . post2. path
206+         ) ) ,  TestRequest . post2. response) 
207+ 
208+         // only available under group prefix
209+         XCTAssertNil ( try   self . app. request ( TestRequest . get1) ) 
210+         XCTAssertNil ( try   self . app. request ( TestRequest . get2) ) 
211+         XCTAssertNil ( try   self . app. request ( TestRequest . post1) ) 
212+         XCTAssertNil ( try   self . app. request ( TestRequest . post2) ) 
213+ 
214+         // defined outside group --> still available without group prefix
215+         XCTAssertEqual ( try   self . app. request ( TestRequest . get3) ,  TestRequest . get3. response) 
216+     } 
170217} 
171218
172219/// Runs the specified callback on a request / response.
0 commit comments