File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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} ) ;
Original file line number Diff line number Diff line change 1+ const matchesSegment = ( pathname : string , prefix : string ) : boolean => {
2+ return pathname === prefix || pathname . startsWith ( prefix + "/" ) ;
3+ } ;
4+
15export 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
You can’t perform that action at this time.
0 commit comments