diff --git a/src/modules/aiTools/ai-tools.service.ts b/src/modules/aiTools/ai-tools.service.ts index 1910b3f..7e2f303 100644 --- a/src/modules/aiTools/ai-tools.service.ts +++ b/src/modules/aiTools/ai-tools.service.ts @@ -81,6 +81,11 @@ export class AiToolsService { text: string ) { try { + const urlRegex = /(https?:\/\/[^\s]+)|(www\.[^\s]+)/g; + const urls = text.match(urlRegex) || []; + + const placeHolder = "9kBjf325" //placeholder which stays the same across languages after translation + const textWithoutUrls = text.replace(urlRegex, placeHolder) let config = { "language": { "sourceLanguage": source, @@ -89,7 +94,7 @@ export class AiToolsService { } let bhashiniConfig: any = await this.getBhashiniConfig('translation',config) - let textArray = text.split("\n") + let textArray = textWithoutUrls.split("\n") for(let i=0;i urls.shift() || ''); return { - text: textArray.join('\n'), + text: translatedText, error: null } } catch(error){