Skip to content

Commit

Permalink
fix(readpcap): remove file extension restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
lanathlor committed Jan 23, 2025
1 parent 68a9874 commit 69fad17
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions cmd/ctl/compose/readpcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"errors"
"os"
"path/filepath"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -39,7 +38,7 @@ func readPcap(cmd *cobra.Command, args []string) error {
return errors.New("pcap file path is required")
}
pcapFile := args[0]
if err := checkFile(pcapFile, ".pcap"); err != nil {
if err := checkFile(pcapFile); err != nil {
return err
}
// Get flags
Expand All @@ -60,7 +59,7 @@ func readPcap(cmd *cobra.Command, args []string) error {
}

// checkFile checks if a file exists and has the specified extension.
func checkFile(filePath, ext string) error {
func checkFile(filePath string) error {
// Check if file exists
info, err := os.Stat(filePath)
if os.IsNotExist(err) {
Expand All @@ -75,10 +74,5 @@ func checkFile(filePath, ext string) error {
return errors.New("not a regular file")
}

// Check file extension
if filepath.Ext(filePath) != ext {
return errors.New("file does not have the correct extension")
}

return nil
}

0 comments on commit 69fad17

Please sign in to comment.