Attempt at fixing the slice

This commit is contained in:
Kuba Orlik 2022-07-18 11:05:12 +02:00
parent 7fc974e744
commit e6b7142829

View File

@ -17,23 +17,16 @@ app.use(async (ctx) => {
"kontakt@midline.pl";
parsed_data.rss.channel[0]["itunes:owner"][0]["itunes:name"] =
"Arkadiusz Wieczorek, Kuba Orlik";
parsed_data.rss.channel[0]["link"] =
"https://www.internet-czas-dzialac.pl";
parsed_data.rss.channel[0]["link"] = "https://www.internet-czas-dzialac.pl";
parsed_data.rss.channel[0]["itunes:keywords"][0] =
parsed_data.rss.channel[0]["itunes:keywords"][0]
.split(" ")
.toString();
parsed_data.rss.channel[0]["itunes:keywords"][0].split(" ").toString();
parsed_data.rss.channel[0]["itunes:summary"][0] =
parsed_data.rss.channel[0]["itunes:summary"][0].replace(
/(<([^>]+)>)/gi,
""
);
for (
let i = 0;
i < parsed_data.rss.channel[0]["atom:link"].length;
i++
) {
for (let i = 0; i < parsed_data.rss.channel[0]["atom:link"].length; i++) {
const atomLink = parsed_data.rss.channel[0]["atom:link"][i];
if (atomLink.$.rel === "self") {
@ -47,18 +40,15 @@ app.use(async (ctx) => {
item["guid"][0].$.isPermaLink = item["guid"][0].$.isPermalink;
delete item["guid"][0].$.isPermalink;
item["itunes:subtitle"][0].length < 255
? item["itunes:subtitle"][0]
: item["itunes:subtitle"][0].slice(0, 255) + "…";
const subtitle = item["itunes:subtitle"][0];
subtitle.length < 254 ? subtitle : subtitle.slice(0, 254) + "…";
item["itunes:summary"][0] = item["itunes:summary"][0].replace(
/(<([^>]+)>)/gi,
""
);
if (item["title"][0].match(/#[0-9]*/)[0].substring(1) !== "0") {
try {
last_index = item["title"][0]
.match(/#[1-9][0-9]*/)[0]
.substring(1);
last_index = item["title"][0].match(/#[1-9][0-9]*/)[0].substring(1);
} catch (e) {
last_index = last_index + 1;
}