UNPKG

@grafana/alerting

Version:

Grafana Alerting Library – Build vertical integrations on top of the industry-leading alerting solution

30 lines (27 loc) 966 B
import { config } from '@grafana/runtime'; "use strict"; const getAPINamespace = () => config.namespace; const getAPIBaseURL = (group, version) => { const subPath = config.appSubUrl || ""; return `${subPath}/apis/${group}/${version}/namespaces/${getAPINamespace()}`; }; const getAPIReducerPath = (group, version) => `${group}/${version}`; const isWellFormed = (str) => { try { encodeURIComponent(str); return true; } catch (error) { return false; } }; const base64UrlEncode = (value) => { if (!isWellFormed(value)) { throw new Error(`Cannot encode malformed UTF-16 string with lone surrogates: ${value}`); } const bytes = new TextEncoder().encode(value); const binString = String.fromCodePoint(...bytes); const base64 = btoa(binString); return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); }; export { base64UrlEncode, getAPIBaseURL, getAPINamespace, getAPIReducerPath }; //# sourceMappingURL=util.mjs.map