Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/commands/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 0 additions & 9 deletions internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"regexp"
"strings"
"time"
"unicode/utf8"

"github.com/clippingkk/cli/internal/models"
)
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions internal/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message on this line reflects the old expected value '#100-101', which could be confusing when debugging a test failure. Please update it to match the new expectation.

Suggested change
t.Errorf("Expected pageAt '#100-101', got '%s'", first.PageAt)
t.Errorf("Expected pageAt '#7', got '%s'", first.PageAt)

}

Expand Down Expand Up @@ -180,4 +180,4 @@ func TestParseTitle(t *testing.T) {
t.Errorf("parseTitle('%s') = '%s', expected '%s'", test.input, result, test.expected)
}
}
}
}