Initial commit

This commit is contained in:
Melvin Lammerts
2026-02-09 10:05:18 +01:00
committed by Admin
commit 61f0733536
3 changed files with 51 additions and 0 deletions

22
README.md Normal file
View File

@@ -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
```

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module github.com/melvinsh/unhttpx
go 1.19

26
main.go Normal file
View File

@@ -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)
}
}