mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: sanitize file checks
This commit is contained in:
1 parent
50b1fe5124
commit
8f22babe7d
7 files changed
+115
-63
No files matched your search
@@ -5,12 +5,12 @@ const fileTypes = {
|
||||
socket: '-S',
|
||||
}
|
||||
|
||||
function sanitizePath(path) {
|
||||
return path.replace(/[^a-zA-Z0-9._/-]/g, '')
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function buildFileCheckCmd(files) {
|
||||
return files
|
||||
.map(
|
||||
({ path, type, exists }) =>
|
||||
`${exists ? '' : '! '}test ${fileTypes[type] || '-e'} ${path}`
|
||||
)
|
||||
.join(' && ')
|
||||
export function buildFileCheckCmd(file) {
|
||||
const { path, type } = file
|
||||
return ['test', fileTypes[type] || '-e', sanitizePath(path)]
|
||||
}
|
||||
Reference in new issue
Block a user