Handle malformed article URLs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { GoogleGenAI, Modality } from '@google/genai';
|
||||
import { VoiceName } from '../types';
|
||||
import { normalizeUrl } from '../utils/url';
|
||||
|
||||
const getAiClient = () => {
|
||||
const apiKey = process.env.API_KEY;
|
||||
@@ -9,18 +10,6 @@ const getAiClient = () => {
|
||||
return new GoogleGenAI({ apiKey });
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to ensure URL has protocol.
|
||||
* Proxies often fail if 'http/https' is missing.
|
||||
*/
|
||||
const normalizeUrl = (url: string) => {
|
||||
let cleanUrl = url.trim();
|
||||
if (!cleanUrl.startsWith('http://') && !cleanUrl.startsWith('https://')) {
|
||||
return `https://${cleanUrl}`;
|
||||
}
|
||||
return cleanUrl;
|
||||
};
|
||||
|
||||
/**
|
||||
* List of CORS proxies to try in order.
|
||||
* This improves reliability if one service is down or blocked.
|
||||
|
||||
Reference in New Issue
Block a user