Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/status-cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ document.addEventListener('DOMContentLoaded', function() {
if (type === 'workflow') {
return `https://img.shields.io/github/actions/workflow/status/${OWNER}/${REPO}/${workflowFile}`;
} else if (type === 'coverage') {
return `https://img.shields.io/coveralls/github/${OWNER}/${REPO}/main.svg`;
// shields.io deprecated the /coveralls/ path — it now 301-redirects
// to a URL that fails CORS, which breaks reading the SVG body from
// the browser. The current /coverallsCoverage/ endpoint serves the
// badge directly with CORS headers.
return `https://img.shields.io/coverallsCoverage/github/${OWNER}/${REPO}?branch=main`;
}
throw new Error(`Unknown badge type: ${type}`);
}
Expand Down Expand Up @@ -214,7 +218,9 @@ document.addEventListener('DOMContentLoaded', function() {

async function fetchCoverageStatus() {
try {
const badgeUrl = `${buildBadgeUrl('coverage')}?t=${Date.now()}`;
// The coverage badge URL already carries a query (?branch=main), so
// join the cache-buster with & rather than ?.
const badgeUrl = `${buildBadgeUrl('coverage')}&t=${Date.now()}`;

const svgText = await fetch(badgeUrl).then(r => r.text());
const coverage = parseCoverageFromSVG(svgText);
Expand Down
4 changes: 2 additions & 2 deletions tests/status-cards.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe('Status Cards Functions', () => {

test('should build coverage badge URL correctly', () => {
const result = statusAPI.buildBadgeUrl('coverage');
expect(result).toBe('https://img.shields.io/coveralls/github/super3/dashban/main.svg');
expect(result).toBe('https://img.shields.io/coverallsCoverage/github/super3/dashban?branch=main');
});

test('should throw error for unknown badge type', () => {
Expand Down Expand Up @@ -960,7 +960,7 @@ describe('Status Cards Functions', () => {

// With no GitHubAuth setup, it uses default config
expect(fetch).toHaveBeenCalledWith(
expect.stringContaining('https://img.shields.io/coveralls/github/super3/dashban/main.svg?t=')
expect.stringContaining('https://img.shields.io/coverallsCoverage/github/super3/dashban?branch=main&t=')
);
});

Expand Down
Loading