Skip to content

Commit

Permalink
sanitize user input, so when drag and drop the directory also works
Browse files Browse the repository at this point in the history
  • Loading branch information
lugenx committed May 5, 2023
1 parent f92795b commit 57666fd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ let destinationDirectory;
let jsonFiles;

const runFirstQuestion = () => {
rl.question(FIRST_QUESTION, (askedFolderLocation) => {
rl.question(FIRST_QUESTION, (firstAnswer) => {
const askedFolderLocation = firstAnswer.trim().replace(/^['"]|['"]$/g, "");
sourceDirectory = path.normalize(`${askedFolderLocation}/Takeout/Keep/`);

if (
Expand All @@ -45,7 +46,10 @@ const runFirstQuestion = () => {
};

const runSecondQuestion = () => {
rl.question(SECOND_QUESTION, (askedDestinationLocation) => {
rl.question(SECOND_QUESTION, (secondAnswer) => {
const askedDestinationLocation = secondAnswer
.trim()
.replace(/^['"]|['"]$/g, "");
destinationDirectory = path.normalize(askedDestinationLocation);

if (
Expand Down

0 comments on commit 57666fd

Please sign in to comment.