Skip to content

refactor: centralize duplicate MD5 and date-formatting utilities#33

Merged
RavelloH merged 3 commits intomainfrom
copilot/analyze-redundant-function-usage
Mar 18, 2026
Merged

refactor: centralize duplicate MD5 and date-formatting utilities#33
RavelloH merged 3 commits intomainfrom
copilot/analyze-redundant-function-usage

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

Multiple files contained inline re-implementations of identical MD5 hashing and date formatting logic. This consolidates them into shared modules.

New shared modules

  • lib/server/crypto.tscalculateMD5(text): normalized (lowercase + trim) MD5 hash
  • lib/shared/date-format.ts — date formatters: formatDate, formatDateWithDots, formatDateTime, formatDateTimeWithSeconds, formatDateTimeLocale
  • lib/client/media-exif.ts — added formatShotDateTime (consolidated from PhotoDetailClient and PhotoModalClient)

Consumers updated

Module Now imports from
actions/comment.ts, actions/user.ts, actions/message.ts lib/server/crypto
PostCard, AdjacentPostCard, ProjectDetailSections, CommentsSection lib/shared/date-format
CloudReport, CloudHistoryTable, FriendsTable, FriendLinkApplyClient lib/shared/date-format
PhotoDetailClient, PhotoModalClient lib/client/media-exif

Example

Before (repeated across 3 action files):

import crypto from "crypto";
const hash = crypto.createHash("md5").update(email.toLowerCase().trim()).digest("hex");

After:

import { calculateMD5 } from "@/lib/server/crypto";
const hash = calculateMD5(email);

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: RavelloH <68409330+RavelloH@users.noreply.github.com>
@RavelloH
Copy link
Owner

继续

Co-authored-by: RavelloH <68409330+RavelloH@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze project for redundant function usage refactor: centralize duplicate MD5 and date-formatting utilities Mar 18, 2026
@RavelloH RavelloH marked this pull request as ready for review March 18, 2026 03:55
@RavelloH RavelloH merged commit 1bbe740 into main Mar 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants