diff --git a/apps/jingrow/frontend/src/views/HomePage.vue b/apps/jingrow/frontend/src/views/HomePage.vue index 6b52fd3..b55a78b 100644 --- a/apps/jingrow/frontend/src/views/HomePage.vue +++ b/apps/jingrow/frontend/src/views/HomePage.vue @@ -766,10 +766,17 @@ const isValidImageUrl = (url: string): boolean => { if (!url || typeof url !== 'string') return false try { const urlObj = new URL(url) + if (!['http:', 'https:'].includes(urlObj.protocol)) { + return false + } + const pathname = urlObj.pathname.toLowerCase() const imageExtensions = ['.jpg', '.jpeg', '.png', '.webp', '.gif', '.bmp'] - return imageExtensions.some(ext => pathname.endsWith(ext)) || - urlObj.pathname.match(/\.(jpg|jpeg|png|webp|gif|bmp)(\?|$)/i) !== null + + const hasImageExtension = imageExtensions.some(ext => pathname.endsWith(ext)) || + urlObj.pathname.match(/\.(jpg|jpeg|png|webp|gif|bmp)(\?|$)/i) !== null + + return hasImageExtension || pathname.length > 0 } catch { return false } diff --git a/apps/jingrow/frontend/src/views/tools/remove_background/remove_background.vue b/apps/jingrow/frontend/src/views/tools/remove_background/remove_background.vue index 507555e..01616ca 100644 --- a/apps/jingrow/frontend/src/views/tools/remove_background/remove_background.vue +++ b/apps/jingrow/frontend/src/views/tools/remove_background/remove_background.vue @@ -308,10 +308,17 @@ const isValidImageUrl = (url: string): boolean => { if (!url || typeof url !== 'string') return false try { const urlObj = new URL(url) + if (!['http:', 'https:'].includes(urlObj.protocol)) { + return false + } + const pathname = urlObj.pathname.toLowerCase() const imageExtensions = ['.jpg', '.jpeg', '.png', '.webp', '.gif', '.bmp'] - return imageExtensions.some(ext => pathname.endsWith(ext)) || - urlObj.pathname.match(/\.(jpg|jpeg|png|webp|gif|bmp)(\?|$)/i) !== null + + const hasImageExtension = imageExtensions.some(ext => pathname.endsWith(ext)) || + urlObj.pathname.match(/\.(jpg|jpeg|png|webp|gif|bmp)(\?|$)/i) !== null + + return hasImageExtension || pathname.length > 0 } catch { return false }