@@ -240,7 +240,8 @@ func (n *node) insertChild(path, fullPath string, handle Handle) {
240
240
"' conflicts with existing children in path '" + fullPath + "'" )
241
241
}
242
242
243
- if wildcard [0 ] == ':' { // param
243
+ // param
244
+ if wildcard [0 ] == ':' {
244
245
if i > 0 {
245
246
// Insert prefix before the current wildcard
246
247
n .path = path [:i ]
@@ -271,45 +272,45 @@ func (n *node) insertChild(path, fullPath string, handle Handle) {
271
272
// Otherwise we're done. Insert the handle in the new leaf
272
273
n .handle = handle
273
274
return
275
+ }
274
276
275
- } else { // catchAll
276
- if i + len (wildcard ) != len (path ) {
277
- panic ("catch-all routes are only allowed at the end of the path in path '" + fullPath + "'" )
278
- }
279
-
280
- if len (n .path ) > 0 && n .path [len (n .path )- 1 ] == '/' {
281
- panic ("catch-all conflicts with existing handle for the path segment root in path '" + fullPath + "'" )
282
- }
283
-
284
- // Currently fixed width 1 for '/'
285
- i --
286
- if path [i ] != '/' {
287
- panic ("no / before catch-all in path '" + fullPath + "'" )
288
- }
277
+ // catchAll
278
+ if i + len (wildcard ) != len (path ) {
279
+ panic ("catch-all routes are only allowed at the end of the path in path '" + fullPath + "'" )
280
+ }
289
281
290
- n .path = path [:i ]
282
+ if len (n .path ) > 0 && n .path [len (n .path )- 1 ] == '/' {
283
+ panic ("catch-all conflicts with existing handle for the path segment root in path '" + fullPath + "'" )
284
+ }
291
285
292
- // First node: catchAll node with empty path
293
- child := & node {
294
- wildChild : true ,
295
- nType : catchAll ,
296
- }
297
- n .children = []* node {child }
298
- n .indices = string ('/' )
299
- n = child
300
- n .priority ++
286
+ // Currently fixed width 1 for '/'
287
+ i --
288
+ if path [i ] != '/' {
289
+ panic ("no / before catch-all in path '" + fullPath + "'" )
290
+ }
301
291
302
- // Second node: node holding the variable
303
- child = & node {
304
- path : path [i :],
305
- nType : catchAll ,
306
- handle : handle ,
307
- priority : 1 ,
308
- }
309
- n .children = []* node {child }
292
+ n .path = path [:i ]
310
293
311
- return
294
+ // First node: catchAll node with empty path
295
+ child := & node {
296
+ wildChild : true ,
297
+ nType : catchAll ,
298
+ }
299
+ n .children = []* node {child }
300
+ n .indices = string ('/' )
301
+ n = child
302
+ n .priority ++
303
+
304
+ // Second node: node holding the variable
305
+ child = & node {
306
+ path : path [i :],
307
+ nType : catchAll ,
308
+ handle : handle ,
309
+ priority : 1 ,
312
310
}
311
+ n .children = []* node {child }
312
+
313
+ return
313
314
}
314
315
315
316
// If no wildcard was found, simply insert the path and handle
0 commit comments