trypost/resources/js/composables
Paulo Castellano 6496588bbc
Defuse links in X posts to avoid the link-post fee (#308)
X bills a post containing a URL at a much higher rate than a plain post, and
its algorithm demotes link posts. The X version of a post now rewrites every
URL non-clickable (https://example.com/post becomes example(.)com/post):
scheme and www. dropped, every dot of the host replaced with (.).

Leaving a single dot intact would still leave a resolvable domain for X to
detect, so all of them are broken. A scheme or www. proves a token is a URL on
its own; a bare host only counts when its last label is a delegated TLD, which
is the one thing telling acme.com apart from Node.js. That check runs against
App\Support\LinkTlds, generated from the whole IANA root zone in every form a
TLD can appear in a post -- ASCII, punycode and the Unicode it decodes to --
because whatever X links is what X bills, so a hand-picked subset would leave
us paying for its gaps. If the regex engine bails out on pathological input the
original content is returned instead of crashing the publisher.

The transform lives in the Platform::X arm of ContentSanitizer, so it reaches
publishing and the app/API/MCP previews from one place and cannot touch any
other network. Off by default; opt in with X_DEFUSE_LINKS.

The editor counts characters and renders its preview client-side and cannot ask
the server on every keystroke, so the rewrite is mirrored in TypeScript. PHP
stays the source of truth: a parity test fails if the two TLD sets drift, and a
browser test drives the real editor so the mirror is covered rather than
assumed. Without it the composer promised text the network never receives.

Character limits now measure the text a reader will see: sanitized, then with
markup resolved away. Measuring the raw draft blocked saving posts that publish
fine and let through posts the network rejects, and counted the editor's HTML
toward the limit. Measuring the sanitized form alone would have counted
Telegram's escaped entities, rejecting messages Telegram accepts.

Empty content is handled once inside the sanitizer instead of by a guard
repeated at every call site.
2026-08-29 15:31:05 -03:00
..
echo fix: subscribe to AI generation channel before dispatching the job (#269) 2026-08-10 16:06:37 -03:00
history feat(automations): implement automation features and UI enhancements 2026-05-24 09:17:19 -03:00
useActiveUrl.ts refactor: sidebar active states, notification bell, phone mockup, UI polish 2026-03-30 18:51:04 -03:00
useAiMediaRegeneration.ts fix: subscribe to AI generation channel before dispatching the job (#269) 2026-08-10 16:06:37 -03:00
useCalendarLocale.ts Localize calendar date pickers to the active UI locale (#234) 2026-08-05 21:02:34 -03:00
useDateMaska.ts chore: first commit 2026-01-15 14:24:39 -03:00
useExpandedEditor.ts Structure brand voice and make generated copy platform-aware 2026-06-12 17:09:39 -03:00
useExpressionCompletions.ts feat(automations): multi-format RSS/Atom feeds with dynamic variables 2026-06-16 10:56:08 -03:00
useInitials.ts chore: first commit 2026-01-14 22:13:44 -03:00
useLinkCard.ts refactor(posts): return the card display domain from the backend 2026-07-17 16:24:23 -03:00
useMedia.ts Harden Instagram story image fitting and cover it end to end 2026-07-16 20:09:43 -03:00
useMediaRules.ts Restore media-rule parity and release failed MCP upload tokens. 2026-07-24 22:37:57 -03:00
useOAuthPopup.ts Allow multiple social accounts per network via env (#286) 2026-08-25 07:28:14 -03:00
useOnboardingLiveReload.ts Activation checklist + MCP OAuth authorize UX (#239) (#250) 2026-08-07 20:34:43 -03:00
usePageErrors.ts feat(posts): add validation message for past date selection in PickTimePopover 2026-05-19 16:26:40 -03:00
usePlatformLogo.ts Allow multiple social accounts per network via env (#286) 2026-08-25 07:28:14 -03:00
usePostCompliance.ts Defuse links in X posts to avoid the link-post fee (#308) 2026-08-29 15:31:05 -03:00
usePostStatus.ts feat(social): reschedule publish on PlatformUnavailable instead of failing 2026-05-19 10:03:30 -03:00
useShortcut.ts feat(automations): implement automation features and UI enhancements 2026-05-24 09:17:19 -03:00
useWorkspaceRole.ts refactor(permissions): drop explanatory comments, fix stale PostPolicy docblock 2026-06-22 16:35:27 -03:00
useWorkspaceSettingsTabs.ts MCP: workspace settings, viewer read access, and token access (#241) 2026-08-06 09:54:51 -03:00
useXLinkDefuser.ts Defuse links in X posts to avoid the link-post fee (#308) 2026-08-29 15:31:05 -03:00