|
|
@ -16,13 +16,17 @@ const useAttachment = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
const sources = getPossibleAttachmentSrc(item) |
|
|
|
const sources = getPossibleAttachmentSrc(item) |
|
|
|
for (const source of sources) { |
|
|
|
for (const source of sources) { |
|
|
|
// test if the source is accessible or not
|
|
|
|
try { |
|
|
|
const res = await fetch(source, { method: 'HEAD' }) |
|
|
|
// test if the source is accessible or not
|
|
|
|
if (res.ok) { |
|
|
|
const res = await fetch(source, { method: 'HEAD' }) |
|
|
|
return source |
|
|
|
if (res.ok) { |
|
|
|
} |
|
|
|
return source |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch {} |
|
|
|
} |
|
|
|
} |
|
|
|
return null |
|
|
|
// if no source can be fetched, it could be probably blocked by CORS
|
|
|
|
|
|
|
|
// return original url or built url anyway
|
|
|
|
|
|
|
|
return item.url || `${appInfo.value.ncSiteUrl}/${item.path}` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const openAttachment = async (item: Record<string, any>) => { |
|
|
|
const openAttachment = async (item: Record<string, any>) => { |
|
|
|