commit 61f073353652875a436cf33bc142fb1490348f2b Author: Melvin Lammerts Date: Mon Feb 9 10:05:18 2026 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..456a937 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# unhttpx + +[![Go Reference](https://pkg.go.dev/badge/github.com/melvinsh/unhttpx.svg)](https://pkg.go.dev/github.com/melvinsh/unhttpx) + +Turns a list of URLs into hostnames. + +## Installation + +``` bash +go install -v github.com/melvinsh/unhttpx@latest +``` + +## Usage + +``` bash +$ echo "https://google.com/yo" | unhttpx +google.com + +$ cat urls.txt | unhttpx +hackerone.com +zerocopter.com +``` diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1accabc --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/melvinsh/unhttpx + +go 1.19 diff --git a/main.go b/main.go new file mode 100644 index 0000000..7f6796b --- /dev/null +++ b/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "bufio" + "fmt" + "net/url" + "os" +) + +func main() { + scanner := bufio.NewScanner(os.Stdin) + + for scanner.Scan() { + inputURL := scanner.Text() + parsedURL, err := url.Parse(inputURL) + if err != nil { + fmt.Fprintf(os.Stderr, "Error parsing URL: %v\n", err) + continue + } + fmt.Println(parsedURL.Host) + } + + if err := scanner.Err(); err != nil { + fmt.Fprintf(os.Stderr, "Error reading input: %v\n", err) + } +}