File tree 2 files changed +10
-1
lines changed
components/TemplateVersionEditor
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog"
3
3
import { Stack } from "components/Stack/Stack"
4
4
import { ChangeEvent , FC , useState } from "react"
5
5
import Typography from "@material-ui/core/Typography"
6
+ import { allowedExtensions , isAllowedFile } from "util/templateVersion"
6
7
7
8
export const CreateFileDialog : FC < {
8
9
onClose : ( ) => void
@@ -24,6 +25,14 @@ export const CreateFileDialog: FC<{
24
25
setError ( "File already exists" )
25
26
return
26
27
}
28
+ if ( ! isAllowedFile ( pathValue ) ) {
29
+ setError (
30
+ `This is not an allowed extension. Valid extensions are: ${ allowedExtensions . join (
31
+ ", " ,
32
+ ) } .`,
33
+ )
34
+ return
35
+ }
27
36
onConfirm ( pathValue )
28
37
setPathValue ( "" )
29
38
}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export const getTemplateVersionFiles = async (
23
23
return files
24
24
}
25
25
26
- const allowedExtensions = [ "tf" , "md" , "Dockerfile" ]
26
+ export const allowedExtensions = [ "tf" , "md" , "Dockerfile" ]
27
27
28
28
export const isAllowedFile = ( name : string ) => {
29
29
return allowedExtensions . some ( ( ext ) => name . endsWith ( ext ) )
You can’t perform that action at this time.
0 commit comments