change: getFilenameWithoutExtension

This commit is contained in:
debugtalk
2021-10-11 18:23:16 +08:00
parent cfa160bcb9
commit b44c94d8b9

View File

@@ -19,8 +19,7 @@ type HAR struct {
}
func (h *HAR) GenJSON() (jsonPath string, err error) {
ext := filepath.Ext(h.path)
jsonPath = h.path[0:len(h.path)-len(ext)] + ".json"
jsonPath = getFilenameWithoutExtension(h.path) + ".json"
tCase := h.makeTestCase()
err = tCase.Dump2JSON(jsonPath)
@@ -28,8 +27,7 @@ func (h *HAR) GenJSON() (jsonPath string, err error) {
}
func (h *HAR) GenYAML() (yamlPath string, err error) {
ext := filepath.Ext(h.path)
yamlPath = h.path[0:len(h.path)-len(ext)] + ".yaml"
yamlPath = getFilenameWithoutExtension(h.path) + ".yaml"
tCase := h.makeTestCase()
err = tCase.Dump2YAML(yamlPath)
@@ -55,3 +53,8 @@ func (h *HAR) prepareTestSteps() []*httpboomer.TStep {
var steps []*httpboomer.TStep
return steps
}
func getFilenameWithoutExtension(path string) string {
ext := filepath.Ext(path)
return path[0 : len(path)-len(ext)]
}