initial commit
This commit is contained in:
13
set-image-url.js
Normal file
13
set-image-url.js
Normal file
@@ -0,0 +1,13 @@
|
||||
export const setImage = (image, folder= '/images') => {
|
||||
if (image.charAt(0) !== '/') {
|
||||
image = '/' + image
|
||||
}
|
||||
if (folder.charAt(0) !== '/') {
|
||||
folder = '/' + folder
|
||||
}
|
||||
if (folder.charAt(folder.length - 1) === '/') {
|
||||
folder = folder.slice(0, -1)
|
||||
}
|
||||
|
||||
return '' + process.env.PUBLIC_URL + folder + image
|
||||
}
|
Reference in New Issue
Block a user