Skip to content

Commit e131465

Browse files
committed
fix: link (#3987)
1 parent a345e56 commit e131465

File tree

2 files changed

+5
-5
lines changed
  • packages/service/common/system
  • projects/app/src/pages/api/core/dataset/collection/create

2 files changed

+5
-5
lines changed

packages/service/common/system/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export const isInternalAddress = (url: string): boolean => {
3030
return true;
3131
}
3232

33-
// For non-metadata URLs, check if it's a domain name
33+
// For IP addresses, check if they are internal
3434
const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}$/;
3535
if (!ipv4Pattern.test(hostname)) {
36-
return true;
36+
return false; // Not an IP address, so it's a domain name - consider it external by default
3737
}
3838

3939
// ... existing IP validation code ...

projects/app/src/pages/api/core/dataset/collection/create/link.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ async function handler(req: NextApiRequest): CreateCollectionResponse {
2929
});
3030
const { title = link, content = '' } = result[0];
3131

32-
if (!content) {
33-
return Promise.reject('Can not fetch content from link');
32+
if (!content || content === 'Cannot fetch internal url') {
33+
return Promise.reject(content || 'Can not fetch content from link');
3434
}
3535

3636
const { collectionId, insertResults } = await createCollectionAndInsertData({
3737
dataset,
3838
rawText: content,
3939
createCollectionParams: {
4040
...body,
41-
name: title,
41+
name: title || link,
4242
teamId,
4343
tmbId,
4444
type: DatasetCollectionTypeEnum.link,

0 commit comments

Comments
 (0)