fix: reuse shared issue path parsing in router

This commit is contained in:
Dotta committed 2026-04-15 20:47:00 -05:00
1 parent 4cbab271cf
commit 396e76c398
2 files changed
+7 -6

No files matched your search

+6
View File
@@ -12,6 +12,12 @@ describe("issue-reference", () => {
expect(parseIssuePathIdFromPath("http://localhost:3100/PAP/issues/PAP-1179")).toBe("PAP-1179");
});
it("ignores placeholder issue paths", () => {
expect(parseIssuePathIdFromPath("/issues/:id")).toBeNull();
expect(parseIssuePathIdFromPath("http://localhost:3100/issues/:id")).toBeNull();
expect(parseIssueReferenceFromHref("/issues/:id")).toBeNull();
});
it("normalizes bare identifiers, issue URLs, and issue scheme links into internal links", () => {
expect(parseIssueReferenceFromHref("pap-1271")).toEqual({
issuePathId: "PAP-1271",
+1 -6
View File
@@ -9,12 +9,7 @@ import {
extractCompanyPrefixFromPath,
normalizeCompanyPrefix,
} from "@/lib/company-routes";
function parseIssuePathIdFromPath(pathname: string | null | undefined): string | null {
if (!pathname) return null;
const match = pathname.match(/(?:^|\/)issues\/([^/?#]+)/);
return match?.[1] ?? null;
}
import { parseIssuePathIdFromPath } from "@/lib/issue-reference";
function resolveTo(to: To, companyPrefix: string | null): To {
if (typeof to === "string") {