badge-urls
Version:
Helper functions to generate URLs for all badges / shields from shields.io
20 lines (19 loc) • 572 B
JavaScript
export default function processRow(row) {
const labelCell = row.children.item(0);
const urlCell = row.children.item(2);
if (!labelCell) {
throw new Error("No label cell");
}
if (!urlCell) {
throw new Error("No url cell");
}
const labelText = labelCell.textContent;
const label = labelText?.endsWith(":")
? labelText.substr(0, labelText.length - 1)
: labelText;
const url = urlCell.textContent;
if (label === null || url === null) {
throw new Error("null");
}
return { label, url };
}