Skip to content

Commit 80437c9

Browse files
authored
fix(wrapper): adapt checkForUpdate to new changelog (#2926)
1 parent 03770a9 commit 80437c9

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

jsHelper/spicetifyWrapper.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,18 +2356,37 @@ Spicetify.Playbar = (() => {
23562356
if (!check_spicetify_update || !version || version === "Dev") return;
23572357
// Fetch latest version from GitHub
23582358
try {
2359+
let changelog;
23592360
const res = await fetch("https://api.github.com/repos/spicetify/spicetify-cli/releases/latest");
23602361
const { tag_name, html_url, body } = await res.json();
23612362
const semver = tag_name.slice(1);
2362-
const changelogRawData = body.match(/## What's Changed([\s\S]*?)\r\n\r/)[1];
2363-
const changelog = [...changelogRawData.matchAll(/\r\n\*\s(.+?)\sin\shttps/g)]
2364-
.map(match => {
2365-
const featureData = match[1].split("@");
2366-
const feature = featureData[0];
2367-
const committerID = featureData[1];
2368-
return `<li>${feature}<a href="https://github.com/${committerID}">${committerID}</a></li>`;
2369-
})
2370-
.join("\n");
2363+
const changelogRawDataOld = body.match(/## What's Changed([\s\S]*?)\r\n\r/)?.[1];
2364+
if (changelogRawDataOld) {
2365+
changelog = [...changelogRawDataOld.matchAll(/\r\n\*\s(.+?)\sin\shttps/g)]
2366+
.map(match => {
2367+
const featureData = match[1].split("@");
2368+
const feature = featureData[0];
2369+
const committerID = featureData[1];
2370+
return `<li>${feature}<a href="https://github.com/${committerID}">${committerID}</a></li>`;
2371+
})
2372+
.join("\n");
2373+
} else {
2374+
const sections = body.split("\n## ");
2375+
const filteredSections = sections.filter(section => !section.startsWith("Compatibility"));
2376+
const filteredText = filteredSections.join("\n## ");
2377+
changelog = [...filteredText.matchAll(/- (?:\*\*(.+?)\*\*:? )?(.+?) \(\[(.+?)\]\((.+?)\)\)/g)]
2378+
.map(match => {
2379+
const feature = match[1];
2380+
const description = match[2];
2381+
const prNumber = match[3];
2382+
const prLink = match[4];
2383+
let text = "<li>";
2384+
if (feature) text += `<strong>${feature}</strong>: `;
2385+
text += `${description} (<a href="${prLink}">${prNumber}</a>)</li>`;
2386+
return text;
2387+
})
2388+
.join("\n");
2389+
}
23712390

23722391
if (semver !== version) {
23732392
const content = document.createElement("div");

0 commit comments

Comments
 (0)