Commit e131465d by Archer Committed by archer

fix: link (#3987)

parent a345e565
...@@ -30,10 +30,10 @@ export const isInternalAddress = (url: string): boolean => { ...@@ -30,10 +30,10 @@ export const isInternalAddress = (url: string): boolean => {
return true; 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}$/; const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}$/;
if (!ipv4Pattern.test(hostname)) { 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 ... // ... existing IP validation code ...
......
...@@ -29,8 +29,8 @@ async function handler(req: NextApiRequest): CreateCollectionResponse { ...@@ -29,8 +29,8 @@ async function handler(req: NextApiRequest): CreateCollectionResponse {
}); });
const { title = link, content = '' } = result[0]; const { title = link, content = '' } = result[0];
if (!content) { if (!content || content === 'Cannot fetch internal url') {
return Promise.reject('Can not fetch content from link'); return Promise.reject(content || 'Can not fetch content from link');
} }
const { collectionId, insertResults } = await createCollectionAndInsertData({ const { collectionId, insertResults } = await createCollectionAndInsertData({
...@@ -38,7 +38,7 @@ async function handler(req: NextApiRequest): CreateCollectionResponse { ...@@ -38,7 +38,7 @@ async function handler(req: NextApiRequest): CreateCollectionResponse {
rawText: content, rawText: content,
createCollectionParams: { createCollectionParams: {
...body, ...body,
name: title, name: title || link,
teamId, teamId,
tmbId, tmbId,
type: DatasetCollectionTypeEnum.link, type: DatasetCollectionTypeEnum.link,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment