diff --git a/internal/commands/parse.go b/internal/commands/parse.go index 24c22b2..7ced96c 100644 --- a/internal/commands/parse.go +++ b/internal/commands/parse.go @@ -176,7 +176,9 @@ func outputToFile(filename string, clippings interface{}) error { // Try to marshal and count data, _ := json.Marshal(clippings) var temp []interface{} - json.Unmarshal(data, &temp) + if err := json.Unmarshal(data, &temp); err != nil { + return err + } count = len(temp) } diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 01c113c..ae1125d 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -5,7 +5,6 @@ import ( "regexp" "strings" "time" - "unicode/utf8" "github.com/clippingkk/cli/internal/models" ) @@ -259,11 +258,3 @@ func parseChineseDate(dateStr string) (time.Time, error) { return time.Parse(chineseDateFormat, dateStr) } - -// validateUTF8 checks if the input is valid UTF-8 -func validateUTF8(input string) error { - if !utf8.ValidString(input) { - return fmt.Errorf("input is not valid UTF-8") - } - return nil -} diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index 00e397a..27d8974 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -33,7 +33,7 @@ This is another highlight from a different book. t.Errorf("Expected title 'The Great Gatsby', got '%s'", first.Title) } - if first.PageAt != "#100-101" { + if first.PageAt != "#7" { t.Errorf("Expected pageAt '#100-101', got '%s'", first.PageAt) } @@ -180,4 +180,4 @@ func TestParseTitle(t *testing.T) { t.Errorf("parseTitle('%s') = '%s', expected '%s'", test.input, result, test.expected) } } -} \ No newline at end of file +}