mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-25 17:44:02 +08:00
fix: replace with session ID
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0+2503051147
|
||||
v5.0.0+2503051452
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestDriverExt_Seek(t *testing.T) {
|
||||
err := driver.Swipe(0.5, 0.8, 0.5, 0.2)
|
||||
assert.Nil(t, err)
|
||||
time.Sleep(1 * time.Second)
|
||||
err = driver.Drag(20, y, float64(width)*0.75, y)
|
||||
err = driver.Swipe(20, y, float64(width)*0.6, y)
|
||||
assert.Nil(t, err)
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
||||
@@ -38,15 +38,11 @@ type DriverRequests struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
emptySessionID = "<SessionNotInit>"
|
||||
)
|
||||
|
||||
func NewDriverSession() *DriverSession {
|
||||
timeout := 30 * time.Second
|
||||
session := &DriverSession{
|
||||
ctx: context.Background(),
|
||||
ID: emptySessionID,
|
||||
ID: "",
|
||||
timeout: timeout,
|
||||
client: &http.Client{
|
||||
Timeout: timeout,
|
||||
@@ -101,8 +97,11 @@ func (s *DriverSession) concatURL(urlStr string) (string, error) {
|
||||
}
|
||||
|
||||
// replace with session ID
|
||||
if s.ID != emptySessionID {
|
||||
urlStr = strings.Replace(urlStr, emptySessionID, s.ID, 1)
|
||||
if s.ID != "" && !strings.Contains(urlStr, s.ID) {
|
||||
sessionPattern := regexp.MustCompile(`/session/([^/]+)/`)
|
||||
if matches := sessionPattern.FindStringSubmatch(urlStr); len(matches) != 0 {
|
||||
urlStr = strings.Replace(urlStr, matches[1], s.ID, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理完整 URL
|
||||
|
||||
Reference in New Issue
Block a user