UNPKG

badge-urls

Version:

Helper functions to generate URLs for all badges / shields from shields.io

17 lines (16 loc) 742 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.staticBadge = void 0; var tslib_1 = require("tslib"); var options_1 = require("./options"); var replaceAll_1 = tslib_1.__importDefault(require("../utils/replaceAll")); var colorWithoutHash = function (color) { return color.startsWith("#") ? color.slice(1) : color; }; var escapeString = function (s) { return replaceAll_1.default(replaceAll_1.default(s, "-", "--"), "_", "__"); }; /** Static badges https://img.shields.io */ exports.staticBadge = function (label, message, color, options) { return options_1.urlWithOptions("/badge/" + escapeString(label) + "-" + escapeString(message) + "-" + escapeString(colorWithoutHash(color)), options); };