Proper escaping for the web service.
This commit is contained in:
parent
1bd5cda174
commit
c04d52da73
|
@ -6,7 +6,13 @@ var badge = require('./badge.js');
|
||||||
// Escapes `t` using the format specified in
|
// Escapes `t` using the format specified in
|
||||||
// <https://github.com/espadrine/gh-badges/issues/12#issuecomment-31518129>
|
// <https://github.com/espadrine/gh-badges/issues/12#issuecomment-31518129>
|
||||||
function escapeFormat(t) {
|
function escapeFormat(t) {
|
||||||
return t.replace('_', ' ').replace('__', '_').replace('--', '-');
|
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, '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
camp.route(/^\/(([^-]|--)+)-(([^-]|--)+)-(([^-]|--)+).svg$/,
|
camp.route(/^\/(([^-]|--)+)-(([^-]|--)+)-(([^-]|--)+).svg$/,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user