@@ -128,6 +128,8 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
128
128
n .priority ++
129
129
numParams := countParams (path )
130
130
131
+ parentFullPathIndex := 0
132
+
131
133
// non-empty tree
132
134
if len (n .path ) > 0 || len (n .children ) > 0 {
133
135
walk:
@@ -155,7 +157,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
155
157
children : n .children ,
156
158
handlers : n .handlers ,
157
159
priority : n .priority - 1 ,
158
- fullPath : fullPath ,
160
+ fullPath : n . fullPath ,
159
161
}
160
162
161
163
// Update maxParams (max of all children)
@@ -171,13 +173,15 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
171
173
n .path = path [:i ]
172
174
n .handlers = nil
173
175
n .wildChild = false
176
+ n .fullPath = fullPath [:parentFullPathIndex + i ]
174
177
}
175
178
176
179
// Make new node a child of this node
177
180
if i < len (path ) {
178
181
path = path [i :]
179
182
180
183
if n .wildChild {
184
+ parentFullPathIndex += len (n .path )
181
185
n = n .children [0 ]
182
186
n .priority ++
183
187
@@ -211,6 +215,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
211
215
212
216
// slash after param
213
217
if n .nType == param && c == '/' && len (n .children ) == 1 {
218
+ parentFullPathIndex += len (n .path )
214
219
n = n .children [0 ]
215
220
n .priority ++
216
221
continue walk
@@ -219,6 +224,7 @@ func (n *node) addRoute(path string, handlers HandlersChain) {
219
224
// Check if a child with the next path byte exists
220
225
for i := 0 ; i < len (n .indices ); i ++ {
221
226
if c == n .indices [i ] {
227
+ parentFullPathIndex += len (n .path )
222
228
i = n .incrementChildPrio (i )
223
229
n = n .children [i ]
224
230
continue walk
@@ -369,6 +375,7 @@ func (n *node) insertChild(numParams uint8, path string, fullPath string, handle
369
375
// insert remaining path part and handle to the leaf
370
376
n .path = path [offset :]
371
377
n .handlers = handlers
378
+ n .fullPath = fullPath
372
379
}
373
380
374
381
// nodeValue holds return values of (*Node).getValue method
0 commit comments