Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions apps/blog/src/components/utm-persistence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,29 @@ export function UtmPersistence() {
}

const nextHref = `${targetUrl.pathname}${targetUrl.search}${targetUrl.hash}`;
const internalPathname =
targetUrl.pathname === BLOG_PREFIX
? "/"
: targetUrl.pathname.replace(new RegExp(`^${BLOG_PREFIX}(?:/|$)`), "/");
const nextInternalHref =
`${internalPathname}${targetUrl.search}${targetUrl.hash}`;
const isBlogPath =
targetUrl.pathname === BLOG_PREFIX ||
targetUrl.pathname.startsWith(`${BLOG_PREFIX}/`);
const isModifiedClick =
event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;

if (isInternalLink && anchor.target !== "_blank" && !isModifiedClick) {
if (
isInternalLink &&
isBlogPath &&
anchor.target !== "_blank" &&
!isModifiedClick
) {
const internalPathname =
targetUrl.pathname === BLOG_PREFIX
? "/"
: targetUrl.pathname.replace(
new RegExp(`^${BLOG_PREFIX}(?:/|$)`),
"/",
);
event.preventDefault();
router.push(nextInternalHref);
router.push(
`${internalPathname}${targetUrl.search}${targetUrl.hash}`,
);
return;
}

Expand Down
15 changes: 14 additions & 1 deletion apps/site/src/components/utm-persistence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ export function UtmPersistence() {
const isModifiedClick =
event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;

if (isInternalLink && anchor.target !== "_blank" && !isModifiedClick) {
// Paths proxied to other apps via rewrites — must use full navigation
// so the server-side rewrite kicks in instead of client-side routing.
const isProxiedPath =
targetUrl.pathname === "/docs" ||
targetUrl.pathname.startsWith("/docs/") ||
targetUrl.pathname === "/blog" ||
targetUrl.pathname.startsWith("/blog/");

if (
isInternalLink &&
!isProxiedPath &&
anchor.target !== "_blank" &&
!isModifiedClick
) {
event.preventDefault();
router.push(nextHref);
return;
Expand Down
Loading