fix #1240: losing host port in har2case

This commit is contained in:
debugtalk
2022-05-03 10:46:05 +08:00
parent 8404c677a4
commit 061d267246
3 changed files with 19 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
- feat: add builtin function `environ`/`ENV`
- fix: demo function compatibility
- fix #1240: losing host port in har2case
- change: get hrp version from aliyun OSS file when installing
## v4.0.0-beta (2022-04-24)

View File

@@ -187,7 +187,7 @@ func (s *tStep) makeRequestURL(entry *Entry) error {
log.Error().Err(err).Msg("make request url failed")
return err
}
s.Request.URL = fmt.Sprintf("%s://%s", u.Scheme, u.Hostname()+u.Path)
s.Request.URL = fmt.Sprintf("%s://%s", u.Scheme, u.Host+u.Path)
return nil
}

View File

@@ -142,6 +142,23 @@ func TestGetFilenameWithoutExtension(t *testing.T) {
}
}
func TestMakeRequestURL(t *testing.T) {
har := NewHAR("")
entry := &Entry{
Request: Request{
URL: "http://127.0.0.1:8080/api/login",
},
}
step, err := har.prepareTestStep(entry)
if !assert.NoError(t, err) {
t.Fatal()
}
if !assert.Equal(t, "http://127.0.0.1:8080/api/login", step.Request.URL) {
t.Fatal()
}
}
func TestMakeRequestHeaders(t *testing.T) {
har := NewHAR("")
entry := &Entry{