Skip to content

Commit

Permalink
fix: fix the null pointer when 'kpm pull'.
Browse files Browse the repository at this point in the history
  • Loading branch information
zong-zhe committed Jul 20, 2023
1 parent f5082de commit 3d306c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/cmd_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func KpmPull(c *cli.Context) error {

ociOpt, event := opt.ParseOciOptionFromOciUrl(ociUrlOrPkgName, tag)

if event.Type() == reporter.IsNotUrl || event.Type() == reporter.UrlSchemeNotOci {
if event != nil && (event.Type() == reporter.IsNotUrl || event.Type() == reporter.UrlSchemeNotOci) {
settings := settings.GetSettings()
if settings.ErrorEvent != nil {
return settings.ErrorEvent
Expand Down
4 changes: 3 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,5 +364,7 @@ func RmNewline(s string) string {

// JoinPath will join the 'elem' to the 'base' with '/'.
func JoinPath(base, elem string) string {
return fmt.Sprintf("%s/%s", base, elem)
base = strings.TrimSuffix(base, "/")
elem = strings.TrimPrefix(elem, "/")
return base + "/" + elem
}

0 comments on commit 3d306c7

Please sign in to comment.