mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 05:11:49 +01:00
fix: reuse shared issue path parsing in router
This commit is contained in:
1 parent
4cbab271cf
commit
396e76c398
2 files changed
+7
-6
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in new issue
Block a user