-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added hash to share-link for security (#97)
- Loading branch information
1 parent
3c883b3
commit c5537f2
Showing
10 changed files
with
64 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,5 @@ export const cardColorsMap = { | |
green: '#71CB7F', | ||
midnight: '#442773' | ||
}; | ||
|
||
export const HASH_LENGTH = 6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ export type ImageFile = { | |
export type UpdatedImageFile = { | ||
fileName: string; | ||
data: string; | ||
url: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
import { hashSync } from 'bcryptjs'; | ||
import { HASH_LENGTH } from '@/constants/general'; | ||
|
||
export const capitalize = (sentence?: string): string => { | ||
if (!sentence) return ''; | ||
return sentence.replace(/\b\w/g, (match) => match.toUpperCase()); | ||
}; | ||
|
||
export const bcryptGen = (username: string): string => { | ||
const salt = process.env.HASHING_SALT as string; | ||
if (!salt) return ''; | ||
const hash = hashSync(username, salt); | ||
return hash.slice(-HASH_LENGTH); | ||
}; | ||
|
||
export const extractFilenameWithoutExtension = (input: string): string => { | ||
const parts = input.split('/'); | ||
const filenameWithExtension = parts[parts.length - 1]; | ||
const filenameParts = filenameWithExtension.split('.'); | ||
const filenameWithoutExtension = filenameParts[0]; | ||
return filenameWithoutExtension || ''; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters