Files
shields/lib/path-helpers.js
Paul Melnikow c62534b5fd Move remaining helper functions to lib/ (#1109)
- Clear the regular update cache between unit tests
2017-10-01 22:08:30 -04:00

25 lines
606 B
JavaScript

'use strict';
// Escapes `t` using the format specified in
// <https://github.com/espadrine/gh-badges/issues/12#issuecomment-31518129>
function escapeFormat(t) {
return t
// Inline single underscore.
.replace(/([^_])_([^_])/g, '$1 $2')
// Leading or trailing underscore.
.replace(/([^_])_$/, '$1 ').replace(/^_([^_])/, ' $1')
// Double underscore and double dash.
.replace(/__/g, '_').replace(/--/g, '-');
}
function escapeFormatSlashes(t) {
return escapeFormat(t)
// Double slash
.replace(/\/\//g, '/');
}
module.exports = {
escapeFormat,
escapeFormatSlashes
};