mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
fix: incorrectly formatted urls
This commit is contained in:
parent
74bc388bd6
commit
04410305b8
3 changed files with 26 additions and 9 deletions
|
@ -490,6 +490,13 @@
|
|||
"avatar_url": "https://avatars.githubusercontent.com/u/6765735?v=4",
|
||||
"profile": "https://github.com/schweden1997",
|
||||
"contributions": ["bug"]
|
||||
},
|
||||
{
|
||||
"login": "KibbeWater",
|
||||
"name": "Snow",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/35224538?v=4",
|
||||
"profile": "https://kibbewater.com",
|
||||
"contributions": ["code", "bug"]
|
||||
}
|
||||
],
|
||||
"skipCi": true,
|
||||
|
|
|
@ -20,7 +20,7 @@ test('format a simple contributor', () => {
|
|||
const {options} = fixtures()
|
||||
|
||||
const expected =
|
||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="150px" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
@ -30,7 +30,7 @@ test('format contributor with complex contribution types', () => {
|
|||
const {options} = fixtures()
|
||||
|
||||
const expected =
|
||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a> <a href="#question-kentcdodds" title="Answering Questions">💬</a>'
|
||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="150px" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=kentcdodds" title="Documentation">📖</a> <a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a> <a href="#question-kentcdodds" title="Answering Questions">💬</a>'
|
||||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
@ -53,7 +53,7 @@ test('default image size to 100', () => {
|
|||
delete options.imageSize
|
||||
|
||||
const expected =
|
||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?s=100" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||
'<a href="http://kentcdodds.com"><img src="https://avatars1.githubusercontent.com/u/1500684?size=100" width="100px" height="100px" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/pulls?q=is%3Apr+reviewed-by%3Akentcdodds" title="Reviewed Pull Requests">👀</a>'
|
||||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
@ -63,7 +63,7 @@ test('format contributor with pipes in their name', () => {
|
|||
const {options} = fixtures()
|
||||
|
||||
const expected =
|
||||
'<a href="http://github.com/chrisinajar"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Who | Needs | Pipes?"/><br /><sub><b>Who | Needs | Pipes?</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=pipey" title="Documentation">📖</a>'
|
||||
'<a href="http://github.com/chrisinajar"><img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="150px" alt="Who | Needs | Pipes?"/><br /><sub><b>Who | Needs | Pipes?</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=pipey" title="Documentation">📖</a>'
|
||||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
@ -73,7 +73,7 @@ test('format contributor with no GitHub account', () => {
|
|||
const {options} = fixtures()
|
||||
|
||||
const expected =
|
||||
'<img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="No Github Account"/><br /><sub><b>No Github Account</b></sub><br /><a href="#translation" title="Translation">🌍</a>'
|
||||
'<img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="150px" alt="No Github Account"/><br /><sub><b>No Github Account</b></sub><br /><a href="#translation" title="Translation">🌍</a>'
|
||||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
@ -83,7 +83,7 @@ test('format contributor with no complete name', () => {
|
|||
const {options} = fixtures()
|
||||
|
||||
const expected =
|
||||
'<img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="nocompletename"/><br /><sub><b>nocompletename</b></sub><br /><a href="#translation-nocompletename" title="Translation">🌍</a>'
|
||||
'<img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="150px" alt="nocompletename"/><br /><sub><b>nocompletename</b></sub><br /><a href="#translation-nocompletename" title="Translation">🌍</a>'
|
||||
|
||||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
@ -93,6 +93,6 @@ test('format contributor with quotes in name', () => {
|
|||
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>'
|
||||
'<a href="http://github.com/namelastname"><img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="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)
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ const _ = require('lodash/fp')
|
|||
const formatContributionType = require('./format-contribution-type')
|
||||
|
||||
const avatarTemplate = _.template(
|
||||
'<img src="<%= contributor.avatar_url %>?s=<%= options.imageSize %>" width="<%= options.imageSize %>px;" alt="<%= name %>"/>',
|
||||
'<img src="<%= contributor.avatar_url %>" width="<%= options.imageSize %>px" height="<%= options.imageSize %>px" alt="<%= name %>"/>',
|
||||
)
|
||||
const avatarBlockTemplate = _.template(
|
||||
'<a href="<%= contributor.profile %>"><%= avatar %><br /><sub><b><%= name %></b></sub></a>',
|
||||
|
@ -52,9 +52,19 @@ function escapeName(name) {
|
|||
module.exports = function formatContributor(options, contributor) {
|
||||
const formatter = _.partial(formatContributionType, [options, contributor])
|
||||
const contributions = contributor.contributions.map(formatter).join(' ')
|
||||
|
||||
const contributorAvatarUrl = new URL(contributor.avatar_url)
|
||||
contributorAvatarUrl.searchParams.append(
|
||||
'size',
|
||||
options.imageSize ?? defaultImageSize,
|
||||
)
|
||||
|
||||
const templateData = {
|
||||
contributions,
|
||||
contributor,
|
||||
contributor: {
|
||||
...contributor,
|
||||
avatar_url: contributorAvatarUrl.toString(),
|
||||
},
|
||||
options: _.assign({imageSize: defaultImageSize}, options),
|
||||
}
|
||||
const customTemplate =
|
||||
|
|
Loading…
Reference in a new issue