File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
_official-jokes/app/routes
combobox-resource-route/app/routes Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,10 @@ function validatePassword(password: string) {
36
36
}
37
37
}
38
38
39
- function validateUrl ( url : FormDataEntryValue ) {
40
- if ( typeof url !== "string" ) return ;
39
+ function validateUrl ( url : FormDataEntryValue | null ) {
40
+ if ( typeof url !== "string" ) return "/jokes" ;
41
41
const urls = [ "/jokes" , "/" , "https://remix.run" ] ;
42
- if ( urls . includes ( url ) ) {
43
- return url ;
44
- }
42
+ if ( urls . includes ( url ) ) return url ;
45
43
return "/jokes" ;
46
44
}
47
45
@@ -50,9 +48,7 @@ export const action = async ({ request }: ActionArgs) => {
50
48
const loginType = form . get ( "loginType" ) ;
51
49
const password = form . get ( "password" ) ;
52
50
const username = form . get ( "username" ) ;
53
- const redirectTo = validateUrl (
54
- ( form . get ( "redirectTo" ) as string ) || "/jokes"
55
- ) ;
51
+ const redirectTo = validateUrl ( form . get ( "redirectTo" ) ) ;
56
52
if (
57
53
typeof loginType !== "string" ||
58
54
typeof password !== "string" ||
Original file line number Diff line number Diff line change 6
6
ComboboxPopover ,
7
7
} from "@reach/combobox" ;
8
8
import comboboxStyles from "@reach/combobox/styles.css" ;
9
- import type { LinksFunction } from "@remix-run/react " ;
9
+ import type { LinksFunction } from "@remix-run/node " ;
10
10
import { Form , useFetcher , useSearchParams } from "@remix-run/react" ;
11
11
12
12
import type { Lang } from "~/models/langs" ;
You can’t perform that action at this time.
0 commit comments