슬러그 수정
This commit is contained in:
+4
-17
@@ -226,24 +226,11 @@ function EditorPageInner() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Date();
|
const randomSlug = Array.from({ length: 12 }, () =>
|
||||||
const datePart = [
|
Math.floor(Math.random() * 36).toString(36),
|
||||||
now.getFullYear().toString().padStart(4, "0"),
|
).join("");
|
||||||
(now.getMonth() + 1).toString().padStart(2, "0"),
|
|
||||||
now.getDate().toString().padStart(2, "0"),
|
|
||||||
].join("");
|
|
||||||
|
|
||||||
const timePart = [
|
updateProjectConfig({ slug: randomSlug });
|
||||||
now.getHours().toString().padStart(2, "0"),
|
|
||||||
now.getMinutes().toString().padStart(2, "0"),
|
|
||||||
now.getSeconds().toString().padStart(2, "0"),
|
|
||||||
].join("");
|
|
||||||
|
|
||||||
const randomPart = Math.random().toString(36).slice(2, 6);
|
|
||||||
|
|
||||||
const generatedSlug = `page-${datePart}-${timePart}-${randomPart}`;
|
|
||||||
|
|
||||||
updateProjectConfig({ slug: generatedSlug });
|
|
||||||
}, [searchParams, projectConfig?.slug, updateProjectConfig]);
|
}, [searchParams, projectConfig?.slug, updateProjectConfig]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ describe("EditorPage - 서버 자동 저장", () => {
|
|||||||
|
|
||||||
expect(typeof body.slug).toBe("string");
|
expect(typeof body.slug).toBe("string");
|
||||||
expect(body.slug).not.toBe("my-landing");
|
expect(body.slug).not.toBe("my-landing");
|
||||||
|
expect(body.slug.startsWith("page-")).toBe(false);
|
||||||
expect(mockState.projectConfig.slug).toBe(body.slug);
|
expect(mockState.projectConfig.slug).toBe(body.slug);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user