31 lines
962 B
TypeScript
31 lines
962 B
TypeScript
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
|
|
|
export function subscriptionCheckoutPath(tenantSlug: string, path?: string) {
|
|
const tenantSegment = tenantSlug.trim();
|
|
if (!tenantSegment) {
|
|
throw new Error("tenantSlug is required");
|
|
}
|
|
|
|
const encodedTenant = encodeURIComponent(tenantSegment);
|
|
const normalizedPath = path?.trim();
|
|
|
|
if (!normalizedPath) {
|
|
return `/subscribe/${encodedTenant}`;
|
|
}
|
|
|
|
if (normalizedPath.startsWith("?") || normalizedPath.startsWith("#")) {
|
|
return `/subscribe/${encodedTenant}${normalizedPath}`;
|
|
}
|
|
|
|
return `/subscribe/${encodedTenant}/${normalizedPath.replace(/^\/+|\/+$/g, "")}`;
|
|
}
|
|
|
|
export function subscriptionRequiredCheckoutPath(tenantSlug: string) {
|
|
const tenantSegment = tenantSlug.trim();
|
|
if (!tenantSegment) {
|
|
throw new Error("tenantSlug is required");
|
|
}
|
|
|
|
return appPath({ tenantSlug: tenantSegment, path: "settings/billing?subscription_required=1", mode: "host-aware" });
|
|
}
|