close
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
22 changes: 21 additions & 1 deletion packages/sdk/src/schema/pages.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, test, expect } from "vitest";
import { OldPagePath, ProjectNewRedirectPath } from "./pages";
import { OldPagePath, PagePath, ProjectNewRedirectPath } from "./pages";

describe("OldPagePath", () => {
describe("basic validation", () => {
Expand Down Expand Up @@ -192,6 +192,26 @@ describe("OldPagePath", () => {
});
});

describe("PagePath", () => {
describe("path length validation", () => {
test("accepts a path of exactly 255 characters", () => {
const path = "/" + "a".repeat(254);
expect(PagePath.safeParse(path).success).toBe(true);
});

test("rejects a path exceeding 255 characters", () => {
const path = "/" + "a".repeat(255);
const result = PagePath.safeParse(path);
expect(result.success).toBe(false);
if (!result.success) {
expect(result.error.issues[0].message).toBe(
"Path can't exceed 255 characters"
);
}
});
});
});

describe("ProjectNewRedirectPath", () => {
test("accepts relative paths", () => {
expect(ProjectNewRedirectPath.safeParse("/about").success).toBe(true);
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/schema/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ const DefaultPagePage = z
// And we cannot customize it due to bug in Remix: https://github.com/remix-run/remix/issues/2933
(path) => path !== "/build" && path.startsWith("/build/") === false,
"/build prefix is reserved for the system"
);
)
.refine((path) => path.length <= 255, "Path can't exceed 255 characters");

export const OldPagePath = z
.string()
Expand Down
Loading