summaryrefslogtreecommitdiff
path: root/scripts/feed.js
diff options
context:
space:
mode:
authorDoge <[email protected]>2021-05-28 11:07:09 +0800
committerDoge <[email protected]>2021-05-28 11:07:09 +0800
commit8509a71e550b0776e3af72230930665a01efb773 (patch)
tree6bb92041aa9a1227bd830c8a6f6b123250083e67 /scripts/feed.js
parent23ead76b3eafd3ab033aa7507b6620962a1be3ae (diff)
downloadchromate-8509a71e550b0776e3af72230930665a01efb773.tar.gz
chromate-8509a71e550b0776e3af72230930665a01efb773.tar.bz2
chromate-8509a71e550b0776e3af72230930665a01efb773.zip
Fix invalid relative url in player and feed
Diffstat (limited to 'scripts/feed.js')
-rw-r--r--scripts/feed.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/feed.js b/scripts/feed.js
index 87e672b..f1a2fc9 100644
--- a/scripts/feed.js
+++ b/scripts/feed.js
@@ -6,6 +6,7 @@ hexo.extend.generator.register("feed", (locals) => {
const config = hexo.config;
const theme = hexo.theme.config;
const urler = hexo.extend.helper.get("url_for").bind(hexo);
+ const fullurl = hexo.extend.helper.get("full_url_for").bind(hexo);
const hstrip = hexo.extend.helper.get("strip_html").bind(hexo);
if (!theme.rss || !theme.rss.enable) return;
@@ -54,6 +55,12 @@ hexo.extend.generator.register("feed", (locals) => {
.replace(/id=".*?"/gi, '').replace(/rel=".*?"/gi, '')
.replace(/title=".*?"/gi, '').replace(/\n/g, "")
.replace(/\s+/g, ' ').trim();
+
+ // Check local media url
+ let url = post.podcast.media.url;
+ if (!(url.startsWith("http://") || url.startsWith("https://")))
+ url = fullurl(post.path, {relative: false}).replace("index.html", '') + url;
+
feed.addItem({
title: post.title,
description: description,