Initial commit
This commit is contained in:
22
README.md
Normal file
22
README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# unhttpx
|
||||
|
||||
[](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
|
||||
```
|
||||
26
main.go
Normal file
26
main.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user