Skip to content

Fix custom isUrl overrides for internal link shortcuts#4919

Merged
zbeyens merged 2 commits intomainfrom
codex/4591-custom-isurl-internal-links
Mar 28, 2026
Merged

Fix custom isUrl overrides for internal link shortcuts#4919
zbeyens merged 2 commits intomainfrom
codex/4591-custom-isurl-internal-links

Conversation

@zbeyens
Copy link
Copy Markdown
Member

@zbeyens zbeyens commented Mar 28, 2026

Summary

Custom isUrl callbacks could not veto /... and #... link shortcuts because validateUrl returned early for internal paths and anchors before it ever consulted the configured validator.

This change only gives that veto power to real custom isUrl callbacks. The default platejs validator still preserves the existing internal-path and anchor-link behavior.

What Changed

  • detect when the configured isUrl is a custom override instead of the default validator
  • respect that custom validator for internal paths and anchor links
  • add regression coverage for validateUrl and upsertLink
  • add a patch changeset for @platejs/link

Testing

  • bun test packages/link/src/lib/utils/validateUrl.spec.ts packages/link/src/lib/transforms/upsertLink.spec.tsx packages/link/src/lib/withLink.spec.tsx
  • pnpm install
  • pnpm turbo build --filter=./packages/link
  • pnpm turbo typecheck --filter=./packages/link
  • pnpm lint:fix
  • pnpm check

Fixes #4591.

@zbeyens zbeyens requested a review from a team March 28, 2026 23:44
@codesandbox
Copy link
Copy Markdown

codesandbox bot commented Mar 28, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 28, 2026

🦋 Changeset detected

Latest commit: 7868135

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@platejs/link Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plate Ready Ready Preview, Comment Mar 28, 2026 11:50pm

Request Review

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 28, 2026
@dosubot dosubot bot added patch Bugfix & documentation PR plugin:link regression labels Mar 28, 2026
@zbeyens zbeyens merged commit e777362 into main Mar 28, 2026
3 checks passed
@zbeyens zbeyens deleted the codex/4591-custom-isurl-internal-links branch March 28, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bugfix & documentation PR plugin:link regression size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

don't want insert internal links starting with /

1 participant