Skip to content

[Remove] test-only external URL predicate - #436

Merged
juanmaguitar merged 2 commits into
trunkfrom
juanmaguitar/cleanup-428
Sep 11, 2026
Merged

juanmaguitar merged 2 commits into
trunkfrom
juanmaguitar/cleanup-428

Conversation

@juanmaguitar

Copy link
Copy Markdown
Collaborator

Why

isAllowedExternalUrl() only restated whether normalizeExternalUrl() returned a value and existed solely for tests. Keeping that duplicate API made the tests assert an implementation wrapper instead of URL normalization behavior.

What changes

Remove the test-only predicate from src/external-url.js. The former tests now assert normalizeExternalUrl()'s returned normalized URL or refusal directly, while existing opening coverage remains intact.

How to test this

Platforms: any — this is a pure URL-normalization module with no platform-specific branch.

Starting state:

  1. Check out this branch with dependencies installed.
  2. Run node --test tests/unit/external-url.test.cjs.

Expected result: the focused suite passes, including parsed-scheme normalization and refused file: URLs.

What must not have happened: invalid or non-HTTP(S) input must not reach the openExternal recorder; normalized HTTP(S) URLs must still be the values handed to it.

No visible UI surface changed; the focused test command demonstrates this internal cleanup.

Risks and limitations

The removed export was intentionally test-only; a downstream consumer importing it would now fail, but repository-wide search found none. Self-review: 0 findings across the five required dimensions.

Related

Fixes #428.


Design decisions and alternatives considered

The assertions were folded into direct normalization checks rather than deleted wholesale, retaining coverage of the parser-derived protocol and output that callers actually use.

Review outcome (required — see AGENTS.md)

0 [fix here] · 0 [follow-up] — no findings across architecture, security, performance, cross-platform behavior, or tests.

Implementation notes

Validation: node --test tests/unit/external-url.test.cjs (11 passing), npm run lint, and npm test (1,258 passing). The unrelated pre-existing package-lock.json modification was left uncommitted.

@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

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c9b8b1f0-3071-483d-8e40-83c589d0c65d

📥 Commits

Reviewing files that changed from the base of the PR and between c1533bd and b3678b4.

📒 Files selected for processing (2)
  • src/external-url.js
  • tests/unit/external-url.test.cjs
💤 Files with no reviewable changes (1)
  • src/external-url.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change removes the test-only isAllowedExternalUrl function and its export. Unit tests no longer import the function. The scheme tests now assert the results of normalizeExternalUrl for HTTPS and file URLs.

Assessment against linked issues

Objective Addressed Explanation
Remove isAllowedExternalUrl() and fold its assertions into the URL normalization contract [#428] ✅
Preserve URL allow-list coverage [#428] ✅
Pass npm run lint and npm test [#428] ❓ No command results are provided.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to b3678

This cleanup preserves the existing external URL behavior and is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description includes the required rationale, changes, testing steps, risks, related issue, design decisions, review outcome, and implementation notes. It clearly explains the removal of isAllowedE…

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 10, 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

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 completed: 0 [fix here], 0 [follow-up] across architecture, security, performance, cross-platform, and tests. Fresh independent judgement pass verified the removed predicate has no consumers and normalization coverage remains. Local lint and all 1,251 tests pass on Node 24.18.0. CodeRabbit has no inline findings; its review attempts are rate limited. Required CI must pass before merge.

@juanmaguitar
juanmaguitar merged commit d06630e into trunk Sep 11, 2026
8 checks passed
@juanmaguitar
juanmaguitar deleted the juanmaguitar/cleanup-428 branch September 11, 2026 05:10
juanmaguitar added a commit that referenced this pull request Sep 11, 2026
## 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.

1. Run `node --test tests/unit/external-url.test.cjs
tests/unit/safe-log.test.cjs`.
2. 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

---

<details>
<summary>Design decisions and alternatives considered</summary>

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.

</details>

<details>
<summary>Review outcome (required — see AGENTS.md)</summary>

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).

</details>

<details>
<summary>Implementation notes</summary>

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.

</details>
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.

Remove the test-only external URL eligibility predicate

1 participant