All files / lib/partners origin.ts

100% Statements 2/2
100% Branches 4/4
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                  4x                     22x    
/**
 * Where the homeowner pages live, per environment.
 *
 * This used to be a bare `const GO_ORIGIN = "https://go.interioring.com"` in
 * referrals.routes.ts, which meant a partner testing on dev or preview was
 * handed a link into PRODUCTION — their forwarded message pointed at a `/e/`
 * page backed by a different database, so the code resolved to nothing and the
 * referral could never engage. Silent, and only reproducible off production.
 */
const ORIGINS: Record<string, string> = {
	production: "https://go.interioring.com",
	preview: "https://go-preview.decorrocket.com",
	dev: "https://go-dev.decorrocket.com",
	local: "http://localhost:7007",
};
 
export function goOrigin(environment: string | undefined): string {
	// Falls back to production rather than to localhost: an unset ENVIRONMENT
	// on a deployed worker should send a real partner somewhere real, and a
	// link to localhost in a WhatsApp message is unrecoverable.
	return ORIGINS[environment ?? ""] ?? ORIGINS.production;
}