Drop leftover /trust path prefix handling

Portals are host-routed on slug subdomains, so SEO path
stripping and the frontend basename helper were dead code.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-07-21 18:23:06 +02:00
parent 48c7585797
commit e4260d50d3
5 changed files with 26 additions and 78 deletions

View File

@@ -20,7 +20,6 @@
import { FullNameRequiredError, NDASignatureRequiredError } from "@probo/relay";
import { getPathPrefix } from "#/lib/http/pathPrefix";
import { localizedPath, resolveUrlLocale, type UrlLocale } from "#/lib/i18n/locale";
// Markers appended to a post-auth `continue` URL so the portal fires the pending
@@ -38,12 +37,11 @@ export const NEW_REQUEST_PARAM = "new-request";
export const SUBSCRIBE_PARAM = "subscribe";
// Validates a `continue` target before we navigate to it. Only same-origin URLs
// under the portal's path prefix are accepted; anything else falls back to the
// portal home, so a crafted `?continue=` can never bounce the user off-site.
// are accepted; anything else falls back to the portal home, so a crafted
// `?continue=` can never bounce the user off-site.
export function getSafeContinueUrl(param: string | null | undefined): string {
const prefix = getPathPrefix();
const localeHome = localizedPath(resolveUrlLocale(), "/");
const fallback = window.location.origin + (prefix || "") + localeHome;
const fallback = window.location.origin + localeHome;
if (!param) {
return fallback;
@@ -51,10 +49,7 @@ export function getSafeContinueUrl(param: string | null | undefined): string {
try {
const url = new URL(param, window.location.origin);
const underPrefix = prefix === ""
? url.pathname.startsWith("/")
: url.pathname === prefix || url.pathname.startsWith(`${prefix}/`);
if (url.origin === window.location.origin && underPrefix) {
if (url.origin === window.location.origin) {
return window.location.origin + url.pathname + url.search;
}
} catch {

View File

@@ -1,35 +0,0 @@
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import { matchPath } from "react-router";
export function getPathPrefix() {
const match = matchPath(
{ path: "/trust/:id", caseSensitive: false, end: false },
window.location.pathname,
);
let prefix = "";
if (match) {
prefix = `/trust/${match.params.id}`;
}
return prefix;
}

View File

@@ -25,7 +25,6 @@ import { createBrowserRouter, redirect } from "react-router";
import { PageErrorBoundary } from "#/components/errors/PageErrorBoundary";
import { RootErrorBoundary } from "#/components/errors/RootErrorBoundary";
import { getPathPrefix } from "#/lib/http/pathPrefix";
import { localeLayoutLoader } from "#/lib/i18n/localeRedirect";
import { resolveUrlLocale } from "#/lib/i18n/locale";
import { authRoutes } from "#/pages/auth/routes";
@@ -89,7 +88,7 @@ const routes = [
...ndaRoutes,
],
},
// Bare basename root (no locale segment) → guessed locale home.
// Bare root (no locale segment) → guessed locale home.
{
path: "/",
loader: () => {
@@ -100,8 +99,5 @@ const routes = [
},
] satisfies AppRoute[];
// The portal is served under a /trust/{slug} path prefix (or a bare custom
// domain). Match the router basename to that prefix so the routes resolve.
export const router = createBrowserRouter(routes.map(routeFromAppRoute), {
basename: getPathPrefix() || "/",
});
// Host-routed portal (slug subdomain / custom domain); paths are site-root.
export const router = createBrowserRouter(routes.map(routeFromAppRoute));