Skip to content

Commit

Permalink
refactor: 매직 넘버 상수화
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim0914 committed Sep 13, 2023
1 parent a0b1904 commit 81ac9ce
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class PhotoNameGenerator {
private static final Set<String> IMAGE_EXTENSIONS = Set.of("jpeg", "jpg", "png", "webp", "heic", "heif");
private static final String UNDER_BAR = "_";
private static final String DOT = ".";
private static final int UUID_BEGIN_INDEX = 0;
private static final int UUID_END_INDEX = 8;

public static String of(String originalFilename) {
validateFileName(originalFilename);
Expand All @@ -25,7 +27,7 @@ private static String convertNameToPath(String originalFilename) {
if (extension == null) {
throw new IllegalArgumentException("파일 확장자는 반드시 포함되어야 합니다. filename: " + originalFilename);
}
String fileBaseName = UUID.randomUUID().toString().substring(0, 8);
String fileBaseName = UUID.randomUUID().toString().substring(UUID_BEGIN_INDEX, UUID_END_INDEX);
validateFileName(fileBaseName);
validateExtension(extension);

Expand Down

0 comments on commit 81ac9ce

Please sign in to comment.