aboutsummaryrefslogtreecommitdiffsponsor
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2022-04-13 11:17:03 -0500
committerSlack Coder <slackcoder@server.ky>2022-04-13 11:17:03 -0500
commitbb5a1e7b515391888b917b597b7595566b5a22de (patch)
tree863a05f906c2331f999b320d25bb74f73fdb6b52
parent77bea528f8e070a8bab09881f83d2f03e88f08a4 (diff)
downloadpkgtools-go-bb5a1e7b515391888b917b597b7595566b5a22de.tar.xz
installpkg: avoid panic when no extension is given
-rw-r--r--pkgtools.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkgtools.go b/pkgtools.go
index 350ab6a..aaffb75 100644
--- a/pkgtools.go
+++ b/pkgtools.go
@@ -224,7 +224,11 @@ var _ ArchiveReader = (*SlackwarePkg)(nil)
func OpenSlackwarePkg(fp string) (*SlackwarePkg, error) {
var pkg SlackwarePkg
var err error
- pkg.Format = PackageType(filepath.Ext(fp)[1:])
+
+ if v := filepath.Ext(fp); len(v) > 0 {
+ pkg.Format = PackageType(filepath.Ext(fp)[1:])
+ }
+
pkg.file, err = os.Open(fp)
if err != nil {
return nil, err