Skip to content

[Refactor] centralize safe log formatter tests, Fixes #429 - #440

Merged
juanmaguitar merged 6 commits into
trunkfrom
juanmaguitar/cleanup-429
Sep 11, 2026
Merged

juanmaguitar merged 6 commits into
trunkfrom
juanmaguitar/cleanup-429

Conversation

@juanmaguitar

@juanmaguitar juanmaguitar commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Why

external-url duplicated formatter-only coverage through describeRefusedUrl(), even though the shared safe-log module owns the one-line, bounded rendering contract.

What changes

Removes the forwarding export and calls describeRefused() directly at the URL refusal boundary. Formatter coverage now exercises safe-log directly; external-url retains URL normalization and refusal-behavior coverage.

How to test this

Platforms: any — this is a internal refactor with no visible UI change.

Starting state:

  1. Check out this PR branch (targets trunk).

  2. Install the repository dependencies.

  3. Run node --test tests/unit/external-url.test.cjs tests/unit/safe-log.test.cjs.

  4. Run npm run lint and npm test.

What must not have happened:

Refused file:, custom, malformed, and otherwise non-HTTP(S) URLs must still not reach shell.openExternal; refused values must remain one-line and bounded. The focused tests cover this directly, and the full suite covers the integration boundary.

Risks and limitations

No user-visible behavior changed. Parent PR #436 is merged; this PR now targets trunk; the review found 0 [fix here] and 0 [follow-up] findings.

Related

Fixes #429


Design decisions and alternatives considered

The formatter belongs to safe-log, where it is shared by URL, site, and editor refusal paths. Keeping a URL-specific wrapper would preserve a second public surface without adding behavior.

Review outcome (required — see AGENTS.md)

0 [fix here] · 0 [follow-up] — no findings across architecture, security, performance, cross-platform, or tests. npm run lint and npm test passed (1,252 tests on Node 24.18.0).

Implementation notes

PR #436 already merged the test-only external URL predicate removal. Also fixes the integration with #439: the truncation test asserts the observable 121-character output instead of importing the removed constant. Before the fix it failed with 121 !== NaN; after the fix all 12 focused tests pass. The URL refusal callback remains covered for escaping and truncation, and the stale logging comment now names the shared formatter. Fresh independent self-review: no remaining findings.

@juanmaguitar juanmaguitar added the audit-code Follow-up work from the codebase audit label Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6b46198f-c1fe-4e12-9fe0-ae4e155e5398

📥 Commits

Reviewing files that changed from the base of the PR and between d06630e and 8023a70.

📒 Files selected for processing (4)
  • src/external-url.js
  • src/logging.js
  • tests/unit/external-url.test.cjs
  • tests/unit/safe-log.test.cjs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@juanmaguitar

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@juanmaguitar
juanmaguitar force-pushed the juanmaguitar/cleanup-428 branch 4 times, most recently from 495c295 to 2cd741b Compare September 11, 2026 04:11
@juanmaguitar
juanmaguitar force-pushed the juanmaguitar/cleanup-428 branch from 2cd741b to ae3180a Compare September 11, 2026 04:16
@juanmaguitar

Copy link
Copy Markdown
Collaborator Author

Self-review reconciliation: the integration failure with merged #439 is fixed. The pre-fix test reproduced 121 !== NaN; it now checks the observable length without importing the removed constant. Added URL refusal callback coverage for escaped, bounded output and corrected the stale logging comment. Fresh independent five-dimension review: 0 remaining findings. All 12 focused tests, lint, and all 1,252 tests pass on Node 24.18.0. CodeRabbit has no inline findings; review attempts are rate limited.

Base automatically changed from juanmaguitar/cleanup-428 to trunk September 11, 2026 05:10
@juanmaguitar
juanmaguitar merged commit b2a96a1 into trunk Sep 11, 2026
8 checks passed
@juanmaguitar
juanmaguitar deleted the juanmaguitar/cleanup-429 branch September 11, 2026 05:16
juanmaguitar added a commit to amitraj2203/contributor-toolkit that referenced this pull request Sep 11, 2026
Trunk removed isAllowedExternalUrl from external-url.js (WordPress#436) and moved
describeRefusedUrl to describeRefused in safe-log.js (WordPress#439, WordPress#440) after
this branch was opened. The merge was textually clean, so both symbols
resolved to undefined: the first uncancelled navigation would have thrown
inside will-navigate, and a failed openExternal would have thrown inside
its own catch. window-links.js now asks normalizeExternalUrl, and main.js
imports describeRefused from safe-log once.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0123opUnXoxs1CAN7YQ7q8KU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit-code Follow-up work from the codebase audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Centralize safe-log tests and remove the URL formatter alias

1 participant