From 8c8391119bad0a3a485586df3e5e6930ba0c54e4 Mon Sep 17 00:00:00 2001 From: Maximilian Hildebrand Date: Thu, 21 Mar 2024 06:58:07 +0100 Subject: [PATCH] fix http flag, prefer host/scheme from path --- cmd/raw.go | 2 +- pkg/raw.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/raw.go b/cmd/raw.go index ce94b9a..effdc5e 100644 --- a/cmd/raw.go +++ b/cmd/raw.go @@ -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") } diff --git a/pkg/raw.go b/pkg/raw.go index 7ce01bc..8896a18 100644 --- a/pkg/raw.go +++ b/pkg/raw.go @@ -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} }