Skip to content

Commit

Permalink
return error if normalized string result is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kinoute committed Oct 15, 2021
1 parent cabce5b commit 5392922
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"crypto/md5"
"encoding/hex"
"errors"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -50,6 +51,12 @@ func Normalize(str string) (string, error) {
// Get rid of trailing/leading spaces and also multiple spaces
s = strings.TrimSpace(s)
s = space.ReplaceAllString(s, " ")

// Return an error if result is empty
if s == "" {
return "", errors.New("Empty result")
}

return s, err
}

Expand Down

0 comments on commit 5392922

Please sign in to comment.