UNPKG

badge-urls

Version:

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

18 lines (17 loc) 535 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** Converts `pathOrUrl` to a URL object. If the argument is a path, it will be prefix with the `baseUrl` */ function createUrl(urlOrPath, prefix) { try { return new URL(urlOrPath); } catch (_a) { return new URL(prefix + (urlOrPath.length > 0 ? urlOrPath.startsWith("/") ? urlOrPath : "/" + urlOrPath : "")); } } exports.default = createUrl;