Skip to content

Commit

Permalink
add validation for non-printable chars in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
andremralves committed Mar 27, 2023
1 parent 25cd3e5 commit 8f96946
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-ads-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

add validation for non-printable characters
3 changes: 3 additions & 0 deletions packages/create-astro/src/actions/project-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export async function projectName(ctx: Pick<Context, 'cwd' | 'prompt' | 'project
if (!isEmpty(value)) {
return `Directory is not empty!`;
}
// Check for non-printable characters
if (value.match(/[^\x20-\x7E]/g) !== null)
return `Invalid non-printable character present!`;
return true;
},
});
Expand Down

0 comments on commit 8f96946

Please sign in to comment.