Skip to content

refactor(sections-editor): dedupe basename/extension helpers between image and file fields#4908

Merged
pedrofrxncx merged 1 commit into
mainfrom
refactor/sections-editor-dedupe-media-filename-w1
Jul 21, 2026
Merged

refactor(sections-editor): dedupe basename/extension helpers between image and file fields#4908
pedrofrxncx merged 1 commit into
mainfrom
refactor/sections-editor-dedupe-media-filename-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Source: C1 code reduction — found while auditing sections-editor/fields for duplication.

ImageField and FileField each defined byte-identical basename()/extension() helpers (URL → display filename / lowercase extension, used to render the preview file name and extension badge). Collapsed both into a new local module fields/media-filename.ts and import from there.

Payoff: one copy to maintain instead of two that can silently drift; net -30/+2 across the two field files (+13-line new shared module).

Behavior: unchanged — the extracted functions are copied verbatim, only their location changed, so ImageField/FileField render identically.

Reviewer check: cd apps/mesh && bunx tsc --noEmit (green). No existing unit test covers these pure UI-formatting helpers (no trust boundary — they only affect a displayed filename), so no test was added per the coverage-gate policy.

Locally verified: bun run fmt (no changes) and bunx tsc --noEmit in apps/mesh (green). Full CI (lint, full test suite) validates the rest.


Summary by cubic

Deduped filename helpers in the sections editor by extracting identical basename and extension logic from ImageField and FileField into a shared module. No UI or behavior changes.

  • Refactors
    • Moved helpers to apps/mesh/src/web/components/sections-editor/fields/media-filename.ts and updated imports in image-field.tsx and file-field.tsx.
    • Reduces duplication and keeps filename/extension rendering consistent.

Written for commit 6d4f5b5. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx merged commit 28f5472 into main Jul 21, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the refactor/sections-editor-dedupe-media-filename-w1 branch July 21, 2026 01:14
decocms Bot pushed a commit that referenced this pull request Jul 21, 2026
PR: #4908 refactor(sections-editor): dedupe basename/extension helpers between image and file fields
Bump type: patch

- decocms (apps/mesh/package.json): 4.82.12 -> 4.82.13

Deploy-Scope: web
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.

1 participant