fix(feeds.js): add require length attribute to enclosures with correct value
This commit is contained in:
parent
995202b1d6
commit
2dc119415d
4 changed files with 30 additions and 18 deletions
|
@ -24,5 +24,16 @@ export default {
|
|||
generatePermalink: (url, baseUrl) => {
|
||||
if (url?.includes("http") || !baseUrl) return url
|
||||
return `${baseUrl}${url}`
|
||||
},
|
||||
getRemoteFileSize: async (url) => {
|
||||
try {
|
||||
const response = await fetch(url, { method: "HEAD" });
|
||||
if (!response.ok) return 0;
|
||||
const contentLength = response.headers.get("content-length");
|
||||
if (!contentLength) return 0;
|
||||
return parseInt(contentLength, 10);
|
||||
} catch (error) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue