Skip to content

Commit

Permalink
refactor: makeFileName
Browse files Browse the repository at this point in the history
  • Loading branch information
anpigon committed Aug 17, 2022
1 parent 8fd4c05 commit 8274270
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export function isISBN(str: string) {
}

export function makeFileName(book: Book, fileNameFormat: string) {
if (fileNameFormat) {
return replaceVariableSyntax(book, replaceDateInString(fileNameFormat));
}
const titleForFileName = replaceIllegalFileNameCharactersInString(book.title);
if (!book.author) {
return titleForFileName;
}
const authorForFileName = replaceIllegalFileNameCharactersInString(book.author);
if (fileNameFormat) {
return replaceVariableSyntax(book, replaceDateInString(fileNameFormat));
}
return `${titleForFileName} - ${authorForFileName}`;
}

Expand Down

0 comments on commit 8274270

Please sign in to comment.