mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-12 03:09:43 +08:00
fix: parse variables
This commit is contained in:
15
parser.go
15
parser.go
@@ -76,8 +76,21 @@ func parseString(raw string, variablesMapping map[string]interface{}) interface{
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentPosition := matchStartPosition
|
||||||
|
var remainedString string
|
||||||
|
// find next $ location
|
||||||
|
nextStartPosition := strings.Index(raw[currentPosition+1:], "$")
|
||||||
|
if nextStartPosition == -1 { // no $ found
|
||||||
|
remainedString = raw[currentPosition:]
|
||||||
|
// break loop
|
||||||
|
matchStartPosition = len(raw)
|
||||||
|
} else { // found next $
|
||||||
|
matchStartPosition = nextStartPosition
|
||||||
|
remainedString = raw[currentPosition:nextStartPosition]
|
||||||
|
}
|
||||||
|
|
||||||
// append remained string
|
// append remained string
|
||||||
parsedString += raw[matchStartPosition:]
|
parsedString += remainedString
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedString
|
return parsedString
|
||||||
|
|||||||
Reference in New Issue
Block a user