blob: 9f456fcd9fd759a8faa20692d726038c7a64fdc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1
/** Drops the trailing slash of every path but the root. */
function trimmed(pathname: string): string {
return pathname.length > 1 && pathname.endsWith("/")
? pathname.slice(0, -1)
: pathname;
}
/**
* The public pages of product.progmasoft.com and the internal routes that
* render them: the catalog, and one page per product.
*/
export function productRoute(pathname: string): string | null {
const path = trimmed(pathname);
if (path === "/") {
return "/products";
}
const segments = path.split("/");
return segments.length === 2 && /^[a-z0-9-]+$/.test(segments[1] ?? "")
? `/products${path}`
: null;
}
/** The public page of catch3.progmasoft.com. */
export function catch3Route(pathname: string): string | null {
return trimmed(pathname) === "/" ? "/catch3" : null;
}
|