@@ -123,8 +123,6 @@ var (
123
123
parameterConstraintSeparatorChars = []byte {paramConstraintSeparator }
124
124
// list of parameter constraint data start
125
125
parameterConstraintDataStartChars = []byte {paramConstraintDataStart }
126
- // list of parameter constraint data end
127
- parameterConstraintDataEndChars = []byte {paramConstraintDataEnd }
128
126
// list of parameter constraint data separator
129
127
parameterConstraintDataSeparatorChars = []byte {paramConstraintDataSeparator }
130
128
)
@@ -317,7 +315,7 @@ func (routeParser *routeParser) analyseParameterPart(pattern string, customConst
317
315
// find constraint part if exists in the parameter part and remove it
318
316
if parameterEndPosition > 0 {
319
317
parameterConstraintStart = findNextNonEscapedCharsetPosition (pattern [0 :parameterEndPosition ], parameterConstraintStartChars )
320
- parameterConstraintEnd = findLastCharsetPosition (pattern [0 :parameterEndPosition + 1 ], parameterConstraintEndChars )
318
+ parameterConstraintEnd = strings . LastIndexByte (pattern [0 :parameterEndPosition + 1 ], paramConstraintEnd )
321
319
}
322
320
323
321
// cut params part
@@ -335,7 +333,7 @@ func (routeParser *routeParser) analyseParameterPart(pattern string, customConst
335
333
336
334
for _ , c := range userConstraints {
337
335
start := findNextNonEscapedCharsetPosition (c , parameterConstraintDataStartChars )
338
- end := findLastCharsetPosition (c , parameterConstraintDataEndChars )
336
+ end := strings . LastIndexByte (c , paramConstraintDataEnd )
339
337
340
338
// Assign constraint
341
339
if start != - 1 && end != - 1 {
@@ -421,18 +419,6 @@ func findNextCharsetPosition(search string, charset []byte) int {
421
419
return nextPosition
422
420
}
423
421
424
- // findLastCharsetPosition search the last char position from the charset
425
- func findLastCharsetPosition (search string , charset []byte ) int {
426
- lastPosition := - 1
427
- for _ , char := range charset {
428
- if pos := strings .LastIndexByte (search , char ); pos != - 1 && (pos < lastPosition || lastPosition == - 1 ) {
429
- lastPosition = pos
430
- }
431
- }
432
-
433
- return lastPosition
434
- }
435
-
436
422
// findNextCharsetPositionConstraint search the next char position from the charset
437
423
// unlike findNextCharsetPosition, it takes care of constraint start-end chars to parse route pattern
438
424
func findNextCharsetPositionConstraint (search string , charset []byte ) int {
0 commit comments