From a3064e765f8ec40fe1ed64994b018734efc1a35d Mon Sep 17 00:00:00 2001 From: Melvin Lammerts Date: Mon, 9 Feb 2026 10:04:44 +0100 Subject: [PATCH] Initial commit --- LICENSE.md | 21 +++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ go.mod | 3 +++ main.go | 26 ++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 go.mod create mode 100644 main.go diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b22968b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 ProjectDiscovery, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. 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) + } +}