Skip to content

Commit

Permalink
fix http flag, prefer host/scheme from path
Browse files Browse the repository at this point in the history
  • Loading branch information
m10x committed Mar 21, 2024
1 parent dd8fbb4 commit 8c83911
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func init() {
rootCmd.AddCommand(rawCmd)

rawCmd.PersistentFlags().StringVarP(&rawPath, "raw", "R", "", "Raw file with crawl results")
rawCmd.PersistentFlags().BoolVarP(&httpP, "http", "", false, "Send HTTP Protoco")
rawCmd.PersistentFlags().BoolVar(&httpP, "http", false, "Send HTTP Protocol")
rawCmd.MarkPersistentFlagRequired("raw")
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ func ReadRaw(rawPath string, httpP bool) []structs.Crawl {
}
index++
}
if config.HTTP {
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
crawl.Request.Endpoint = path
} else if httpP {
crawl.Request.Endpoint = "http://" + host + path
} else {
crawl.Request.Endpoint = "https://" + host + path
}

crawl.Request.Body = body
return []structs.Crawl{crawl}
}

0 comments on commit 8c83911

Please sign in to comment.