From e131465d2503245dea4b0b1acb236bea77269ef4 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Wed, 5 Mar 2025 17:08:18 +0800 Subject: [PATCH] fix: link (#3987) --- packages/service/common/system/utils.ts | 4 ++-- .../src/pages/api/core/dataset/collection/create/link.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/service/common/system/utils.ts b/packages/service/common/system/utils.ts index 3151a4394..13837aab4 100644 --- a/packages/service/common/system/utils.ts +++ b/packages/service/common/system/utils.ts @@ -30,10 +30,10 @@ export const isInternalAddress = (url: string): boolean => { return true; } - // For non-metadata URLs, check if it's a domain name + // For IP addresses, check if they are internal const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}$/; if (!ipv4Pattern.test(hostname)) { - return true; + return false; // Not an IP address, so it's a domain name - consider it external by default } // ... existing IP validation code ... diff --git a/projects/app/src/pages/api/core/dataset/collection/create/link.ts b/projects/app/src/pages/api/core/dataset/collection/create/link.ts index 17f365a2a..2c8800434 100644 --- a/projects/app/src/pages/api/core/dataset/collection/create/link.ts +++ b/projects/app/src/pages/api/core/dataset/collection/create/link.ts @@ -29,8 +29,8 @@ async function handler(req: NextApiRequest): CreateCollectionResponse { }); const { title = link, content = '' } = result[0]; - if (!content) { - return Promise.reject('Can not fetch content from link'); + if (!content || content === 'Cannot fetch internal url') { + return Promise.reject(content || 'Can not fetch content from link'); } const { collectionId, insertResults } = await createCollectionAndInsertData({ @@ -38,7 +38,7 @@ async function handler(req: NextApiRequest): CreateCollectionResponse { rawText: content, createCollectionParams: { ...body, - name: title, + name: title || link, teamId, tmbId, type: DatasetCollectionTypeEnum.link,