File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed
src/app/_home/$school/$year Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,13 @@ function getCoursesMap(
114114export const Route = createFileRoute ( "/_home/$school/$year/$id/" ) ( {
115115 params : {
116116 parse : ( { school, year, id } ) => {
117- if ( isSchool ( school ) ) return { school, year : parseInt ( year , 10 ) , id }
118- else throw redirect ( { to : "/" } )
117+ if ( ! isSchool ( school ) ) throw redirect ( { to : "/" } )
118+
119+ const yearInt = parseInt ( year , 10 )
120+ if ( Number . isNaN ( yearInt ) )
121+ throw redirect ( { to : "/$school" , params : { school } } )
122+
123+ return { school, year : yearInt , id }
119124 } ,
120125 } ,
121126 loader : ( { params } ) => {
@@ -194,13 +199,15 @@ function Component({ ranking }: { ranking: NewRanking }) {
194199
195200 return (
196201 < Page
197- className = { `flex items-center gap-4 px-0 ${ isMobile ? "flex-col overflow-y-auto overflow-x-hidden" : ""
198- } `}
202+ className = { `flex items-center gap-4 px-0 ${
203+ isMobile ? "flex-col overflow-y-auto overflow-x-hidden" : ""
204+ } `}
199205 fullWidth
200206 >
201207 < div
202- className = { `flex w-full max-w-7xl flex-col gap-4 px-4 ${ isMobile ? "flex-col overflow-y-auto overflow-x-hidden" : ""
203- } `}
208+ className = { `flex w-full max-w-7xl flex-col gap-4 px-4 ${
209+ isMobile ? "flex-col overflow-y-auto overflow-x-hidden" : ""
210+ } `}
204211 >
205212 < PathBreadcrumb />
206213 < div className = "flex w-full gap-4 max-sm:flex-col sm:items-center" >
Original file line number Diff line number Diff line change @@ -11,8 +11,13 @@ export const Route = createFileRoute("/_home/$school/$year/")({
1111 component : RouteComponent ,
1212 params : {
1313 parse : ( { school, year } ) => {
14- if ( isSchool ( school ) ) return { school, year : parseInt ( year , 10 ) }
15- else throw redirect ( { to : "/" } )
14+ if ( ! isSchool ( school ) ) throw redirect ( { to : "/" } )
15+
16+ const yearInt = parseInt ( year , 10 )
17+ if ( Number . isNaN ( yearInt ) )
18+ throw redirect ( { to : "/$school" , params : { school } } )
19+
20+ return { school, year : yearInt }
1621 } ,
1722 } ,
1823} )
You can’t perform that action at this time.
0 commit comments