Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import path from 'path';
import { URL } from 'url';
const imageExtensionRegex = /\.(jpg|jpeg|png|gif|bmp|tiff|svg|webp)$/i;
/**
* Extracts the image basename from a given URL.
*
* @param urlString - The URL string from which the image basename is to be extracted.
* @returns The basename of the image file from the URL.
* Returns an empty string if the URL does not contain a valid image basename.
*/
export function getImageBasename(urlString: string): string {
try {
const url = new URL(urlString);
const basename = path.basename(url.pathname);
return imageExtensionRegex.test(basename) ? basename : '';
} catch {
// If URL parsing fails, return an empty string
return '';
}
}