Files
shields/core/badge-urls/path-helpers.js
2021-07-09 12:53:55 +01:00

15 lines
374 B
JavaScript

// Escapes `t` using the format specified in
// <https://github.com/espadrine/gh-badges/issues/12#issuecomment-31518129>
function escapeFormat(t) {
return (
t
// Single underscore.
.replace(/(^|[^_])((?:__)*)_(?!_)/g, '$1$2 ')
// Double underscore and double dash.
.replace(/__/g, '_')
.replace(/--/g, '-')
)
}
export { escapeFormat }