Skip to content

Commit 36ce04d

Browse files
committed
fix: isHiddenPath 경로 세그먼트 매칭 오류 수정
1 parent d9d7edc commit 36ce04d

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

src/shared/const/__tests__/headerValues.test.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,11 @@ describe("isHiddenPath", () => {
5050
expect(isHiddenPath("/schedule")).toBe(false);
5151
});
5252

53-
it("숨김 prefix와 비슷하지만 다른 경로에서 false를 반환한다", () => {
54-
// /sign은 /signin, /signup 어디에도 해당하지 않음
53+
it("숨김 prefix와 비슷하지만 독립된 경로에서 false를 반환한다", () => {
5554
expect(isHiddenPath("/sign")).toBe(false);
56-
});
57-
});
58-
59-
describe("startsWith 부작용 - 예상치 못한 true 케이스", () => {
60-
it("/voters는 /vote로 시작하므로 true를 반환한다", () => {
61-
// startsWith("/vote") 조건으로 인해 /vote로 시작하는 모든 경로가 숨김 처리됨
62-
expect(isHiddenPath("/voters")).toBe(true);
55+
expect(isHiddenPath("/voters")).toBe(false);
56+
expect(isHiddenPath("/vote-info")).toBe(false);
57+
expect(isHiddenPath("/admins")).toBe(false);
6358
});
6459
});
6560
});

src/shared/const/headerValues.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
const matchesSegment = (pathname: string, prefix: string): boolean => {
2+
return pathname === prefix || pathname.startsWith(prefix + "/");
3+
};
4+
15
export const isHiddenPath = (pathname: string): boolean => {
26
return (
3-
pathname.startsWith("/signin") ||
4-
pathname.startsWith("/signup") ||
5-
pathname.startsWith("/vote") ||
6-
pathname.startsWith("/admin")
7+
matchesSegment(pathname, "/signin") ||
8+
matchesSegment(pathname, "/signup") ||
9+
matchesSegment(pathname, "/vote") ||
10+
matchesSegment(pathname, "/admin")
711
);
812
};
913

0 commit comments

Comments
 (0)