Skip to content

Commit

Permalink
feat: Add mapping for non-urls
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeine-addictt committed Apr 14, 2024
1 parent 3690c3c commit eb57871
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,15 @@ var getCommand = &cobra.Command{
// Turn all URLS to a map to eliminate duplicates
// We map string: struct{} for the smallest memory footprint
argSet := make(map[string]struct{})
for _, arg := range args {
argSet[arg] = struct{}{}
}
nonURLSet := make(map[string]Similarity)

// Validate explicitly passed URL(s)
if len(argSet) > 0 {
Debug("Validating passed URL(s)")
for rawURL := range argSet {
if _, err := url.ParseRequestURI(rawURL); err != nil {
fmt.Println("Invalid URL: " + rawURL)
os.Exit(1)
}
for _, arg := range args {
if _, err := url.ParseRequestURI(arg); err != nil {
Debug("Invalid URL: " + arg)
nonURLSet[arg] = make(Similarity, 10)
continue
}
argSet[arg] = struct{}{}
}

// Fetch URLs from file
Expand All @@ -109,8 +105,9 @@ var getCommand = &cobra.Command{

// Validate URL
if _, err := url.ParseRequestURI(scanner.Text()); err != nil {
fmt.Println("Invalid URL: " + scanner.Text())
os.Exit(1)
Debug("Invalid URL: " + scanner.Text())
nonURLSet[scanner.Text()] = make(Similarity, 10)
continue
}
argSet[scanner.Text()] = struct{}{}
}
Expand Down

0 comments on commit eb57871

Please sign in to comment.