mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
fix: correct escape quotes in contributor names (#351)
This commit is contained in:
parent
66d29afac5
commit
959e3613bf
3 changed files with 19 additions and 1 deletions
|
@ -34,5 +34,12 @@
|
|||
"name": "Wildly Misconfigured",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
||||
"contributions": ["plumbis"]
|
||||
},
|
||||
"name_with_quotes": {
|
||||
"login": "namelastname",
|
||||
"name": "Name \"Nickname\" Lastname",
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
|
||||
"profile": "http://github.com/namelastname",
|
||||
"contributions": ["doc"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,3 +87,12 @@ test('format contributor with no complete name', () => {
|
|||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
||||
test('format contributor with quotes in name', () => {
|
||||
const contributor = contributors.name_with_quotes
|
||||
const {options} = fixtures()
|
||||
|
||||
const expected =
|
||||
'<a href="http://github.com/namelastname"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Name "Nickname" Lastname"/><br /><sub><b>Name "Nickname" Lastname</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=namelastname" title="Documentation">📖</a>'
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
|
|
@ -44,7 +44,9 @@ function defaultTemplate(templateData) {
|
|||
}
|
||||
|
||||
function escapeName(name) {
|
||||
return name.replace(new RegExp('\\|', 'g'), '|')
|
||||
return name
|
||||
.replace(new RegExp('\\|', 'g'), '|')
|
||||
.replace(new RegExp('\\"', 'g'), '"')
|
||||
}
|
||||
|
||||
module.exports = function formatContributor(options, contributor) {
|
||||
|
|
Loading…
Reference in a new issue