diff --git a/notes_parser.go b/notes_parser.go index 25ea430..40fc718 100644 --- a/notes_parser.go +++ b/notes_parser.go @@ -52,11 +52,17 @@ func parseNoteListItem(item *goquery.Selection) *NotePreview { } // Note ID lives in the href: /msg/pms/{folder}/{id}/#message. Strip the - // fragment first so extractIntFromHref picks the trailing numeric path. + // fragment first, then take the *last* numeric segment — the folder + // number (e.g. 1) appears before the note ID and would otherwise win + // the "first numeric segment" race in extractIntFromHref. if i := strings.Index(href, "#"); i != -1 { href = href[:i] } - np.ID = NoteID(extractIntFromHref(href)) + for _, seg := range strings.Split(href, "/") { + if n, err := parseID[NoteID](seg); err == nil && n != 0 { + np.ID = n + } + } // Read/unread: classes on the subject link. if class, _ := subjectLink.Attr("class"); strings.Contains(class, "note-unread") || strings.Contains(class, "unread") && !strings.Contains(class, "note-read") {