fix(torob): sanitize imageLink in Torob API and feed to always use frontend domain and proxy path
Deploy Canina / deploy (push) Successful in 1m44s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 7s

This commit is contained in:
parsa aghaei committed 2026-08-29 14:18:41 +03:30
1 parent 376fea356f
commit 88060431bb
14 files changed
+9023 -8720

No files matched your search

+13 -8
View File
@@ -42,15 +42,20 @@ export class TorobController {
const nameEn = product.nameEn || '';
const title = nameEn ? `${nameFa} (${nameEn})` : nameFa;
const rawImage = product.ogImage || product.imageUrl || '';
let imageLink = '';
if (product.ogImage) {
imageLink = product.ogImage.startsWith('http')
? product.ogImage
: `${baseUrl}${product.ogImage.startsWith('/') ? product.ogImage : `/${product.ogImage}`}`;
} else if (product.imageUrl) {
imageLink = product.imageUrl.startsWith('http')
? product.imageUrl
: `${baseUrl}/uploads/${product.imageUrl.replace(/^\/?(uploads\/)?/, '')}`;
if (rawImage) {
const cleanImage = rawImage.trim()
.replace(/^https?:\/\/api\.canina\.ir/i, '')
.replace(/^https?:\/\/localhost:\d+/i, '')
.replace(/^https?:\/\/127\.0\.0\.1:\d+/i, '');
if (cleanImage.startsWith('http://') || cleanImage.startsWith('https://')) {
imageLink = cleanImage;
} else {
const cleanPath = cleanImage.replace(/^\/?(api\/)?(uploads\/)?/, '');
imageLink = `${baseUrl}/api/uploads/${cleanPath}`;
}
}
const isInStock = product.stockStatus !== 'DISCONTINUED' && String(product.stockStatus || '').toLowerCase().includes('in');