MCPcopy Create free account
hub / github.com/CatMuse/HiNote / sanitizeComment

Method sanitizeComment

src/storage/DataValidator.ts:305–333  ·  view source on GitHub ↗

* 清理和标准化评论数据 * @param comment 原始评论数据 * @returns 清理后的评论数据

(comment: unknown)

Source from the content-addressed store, hash-verified

303 * @returns 清理后的评论数据
304 */
305 static sanitizeComment(comment: unknown): SanitizedComment {
306 const sanitized: SanitizedComment = {};
307
308 if (!this.isRecord(comment)) {
309 return sanitized;
310 }
311
312 if (comment.id && typeof comment.id === 'string') {
313 sanitized.id = comment.id;
314 }
315
316 if (comment.content && typeof comment.content === 'string') {
317 sanitized.content = comment.content;
318 }
319
320 if (typeof comment.created === 'number') {
321 sanitized.created = comment.created;
322 } else if (typeof comment.createdAt === 'number') {
323 sanitized.created = comment.createdAt;
324 }
325
326 if (typeof comment.updated === 'number') {
327 sanitized.updated = comment.updated;
328 } else if (typeof comment.updatedAt === 'number') {
329 sanitized.updated = comment.updatedAt;
330 }
331
332 return sanitized;
333 }
334}

Callers 1

sanitizeHighlightMethod · 0.95

Calls 1

isRecordMethod · 0.95

Tested by

no test coverage detected