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
36 changes: 6 additions & 30 deletions packages/redirects/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";

import {
defaults,
getRegionRedirectUrl,
getStatsRedirectUrl,
redirects,
} from "./index";
import { getRegionRedirectUrl, getStatsRedirectUrl, redirects } from "./index";

describe("@f3muletown/redirects", () => {
describe("getRegionRedirectUrl", () => {
Expand All @@ -23,28 +18,9 @@ describe("@f3muletown/redirects", () => {
});

describe("getStatsRedirectUrl", () => {
afterEach(() => {
vi.useRealTimers();
});

it("uses the current year and default location when not provided", () => {
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-02-15T10:00:00Z"));

it("returns the stats redirect URL", () => {
expect(getStatsRedirectUrl()).toBe(
"https://www.yourfullstack.com/apps/f3fw/ytd.php?year=2026&location=f3muletown"
);
});

it("accepts custom years and locations", () => {
expect(
getStatsRedirectUrl({ year: 2023, location: defaults.statsLocation })
).toBe(
"https://www.yourfullstack.com/apps/f3fw/ytd.php?year=2023&location=f3muletown"
);

expect(getStatsRedirectUrl({ year: 2025, location: "f3wherever" })).toBe(
"https://www.yourfullstack.com/apps/f3fw/ytd.php?year=2025&location=f3wherever"
"https://pax-vault.f3nation.com/stats/region/35838"
);
});
});
Expand All @@ -61,8 +37,8 @@ describe("@f3muletown/redirects", () => {
});

it("provides a stats shortcut", () => {
expect(redirects.stats({ year: 2030, location: "f3alpha" })).toBe(
"https://www.yourfullstack.com/apps/f3fw/ytd.php?year=2030&location=f3alpha"
expect(redirects.stats()).toBe(
"https://pax-vault.f3nation.com/stats/region/35838"
);
});
});
Expand Down
18 changes: 4 additions & 14 deletions packages/redirects/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
const REGION_BASE_URL = "https://regions.f3nation.com";
const DEFAULT_REGION_SLUG = "muletown";

const STATS_BASE_URL = "https://www.yourfullstack.com/apps/f3fw/ytd.php";
const DEFAULT_STATS_LOCATION = "f3muletown";

export type StatsRedirectOptions = {
year?: number;
location?: string;
};
const STATS_URL = "https://pax-vault.f3nation.com/stats/region/35838";

export const defaults = {
regionSlug: DEFAULT_REGION_SLUG,
statsLocation: DEFAULT_STATS_LOCATION,
} as const;

export function getRegionRedirectUrl(slug: string = DEFAULT_REGION_SLUG) {
return `${REGION_BASE_URL}/${slug}`;
}

export function getStatsRedirectUrl({
year = new Date().getFullYear(),
location = DEFAULT_STATS_LOCATION,
}: StatsRedirectOptions = {}) {
return `${STATS_BASE_URL}?year=${year}&location=${location}`;
export function getStatsRedirectUrl() {
return STATS_URL;
}

export const redirects = {
regionHome: getRegionRedirectUrl,
stats: (options?: StatsRedirectOptions) => getStatsRedirectUrl(options),
stats: getStatsRedirectUrl,
} as const;
Loading