Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: all-contributors/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.25.0
Choose a base ref
...
head repository: all-contributors/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.25.1
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on May 12, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    959e361 View commit details
Showing with 19 additions and 1 deletion.
  1. +7 −0 src/generate/__tests__/fixtures/contributors.json
  2. +9 −0 src/generate/__tests__/format-contributor.js
  3. +3 −1 src/generate/format-contributor.js
7 changes: 7 additions & 0 deletions src/generate/__tests__/fixtures/contributors.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
9 changes: 9 additions & 0 deletions src/generate/__tests__/format-contributor.js
Original file line number Diff line number Diff line change
@@ -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 &quot;Nickname&quot; Lastname"/><br /><sub><b>Name &quot;Nickname&quot; 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)
})
4 changes: 3 additions & 1 deletion src/generate/format-contributor.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,9 @@ function defaultTemplate(templateData) {
}

function escapeName(name) {
return name.replace(new RegExp('\\|', 'g'), '&#124;')
return name
.replace(new RegExp('\\|', 'g'), '&#124;')
.replace(new RegExp('\\"', 'g'), '&quot;')
}

module.exports = function formatContributor(options, contributor) {