Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Dec 23, 2022
1 parent 6f1abcb commit 219e3cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/oras/internal/fileref/unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import (
)

// Parse parses file reference on unix.
func Parse(reference string, mediaType string) (filePath, mediatype string, err error) {
func Parse(reference string, defaultMediaType string) (filePath, mediaType string, err error) {
filePath = reference
mediaType = defaultMediaType

i := strings.LastIndex(reference, ":")
if i >= 0 {
filePath, mediatype = reference[:i], reference[i+1:]
filePath, mediaType = reference[:i], reference[i+1:]
}
if filePath == "" {
return "", "", fmt.Errorf("found empty file path in %q", reference)
}
return filePath, mediatype, nil
return filePath, mediaType, nil
}

0 comments on commit 219e3cc

Please sign in to comment.