diff --git a/lib/generate/fixtures/contributors.json b/lib/generate/fixtures/contributors.json
index 8032036..8e54dbd 100644
--- a/lib/generate/fixtures/contributors.json
+++ b/lib/generate/fixtures/contributors.json
@@ -18,5 +18,14 @@
"contributions": [
"review"
]
+ },
+ "pipey": {
+ "login": "pipey",
+ "name": "Who | Needs | Pipes?",
+ "profile": "http://github.com/chrisinajar",
+ "avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
+ "contributions": [
+ "doc"
+ ]
}
}
diff --git a/lib/generate/format-contributor.js b/lib/generate/format-contributor.js
index 60479fe..24f53cb 100644
--- a/lib/generate/format-contributor.js
+++ b/lib/generate/format-contributor.js
@@ -4,17 +4,25 @@ var _ = require('lodash/fp');
var formatContributionType = require('./format-contribution-type');
var avatarTemplate = _.template('');
-var avatarBlockTemplate = _.template('[<%= avatar %>
<%= contributor.name %>](<%= contributor.profile %>)');
+var avatarBlockTemplate = _.template('[<%= avatar %>
<%= name %>](<%= contributor.profile %>)');
var contributorTemplate = _.template('<%= avatarBlock %>
<%= contributions %>');
var defaultImageSize = 100;
function defaultTemplate(templateData) {
var avatar = avatarTemplate(templateData);
- var avatarBlock = avatarBlockTemplate(_.assign({avatar: avatar}, templateData));
+ var avatarBlock = avatarBlockTemplate(_.assign({
+ name: escapeName(templateData.contributor.name),
+ avatar: avatar
+ }, templateData));
+
return contributorTemplate(_.assign({avatarBlock: avatarBlock}, templateData));
}
+function escapeName(name) {
+ return name.replace(new RegExp('\\|', 'g'), '|');
+}
+
module.exports = function formatContributor(options, contributor) {
var formatter = _.partial(formatContributionType, [options, contributor]);
var contributions = contributor.contributions
diff --git a/lib/generate/format-contributor.test.js b/lib/generate/format-contributor.test.js
index fa6cae0..f9d29a9 100644
--- a/lib/generate/format-contributor.test.js
+++ b/lib/generate/format-contributor.test.js
@@ -49,3 +49,12 @@ test('should default image size to 100', t => {
t.is(formatContributor(options, contributor), expected);
});
+
+test('should format contributor with pipes in their name', t => {
+ const contributor = contributors.pipey;
+ const {options} = fixtures();
+
+ const expected = '[
Who | Needs | Pipes?](http://github.com/chrisinajar)
[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey)';
+
+ t.is(formatContributor(options, contributor), expected);
+});