first commit
This commit is contained in:
12
test-image-url.js
Normal file
12
test-image-url.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Test getImageUrl function
|
||||
const BASE_API_URL = 'http://127.0.0.1:8000'\;
|
||||
const getImageUrl = (imagePath) => {
|
||||
if (!imagePath) return '/assets/images/work/placeholder.jpg'
|
||||
if (imagePath.startsWith('http')) return imagePath
|
||||
return `${BASE_API_URL}${imagePath}`
|
||||
}
|
||||
// Test cases
|
||||
console.log('Test 1 - API path:', getImageUrl('/media/uploads/portfolio/a2afc48f6532427cac863619563e3800.avif'));
|
||||
console.log('Test 2 - Full URL:', getImageUrl('http://example.com/image.jpg'));
|
||||
console.log('Test 3 - Null:', getImageUrl(null));
|
||||
console.log('Test 4 - Empty:', getImageUrl(''));
|
||||
Reference in New Issue
Block a user