Skip to content

Commit 0441030

Browse files
committed
fix: incorrectly formatted urls
1 parent 74bc388 commit 0441030

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

.all-contributorsrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@
490490
"avatar_url": "https://avatars.githubusercontent.com/u/6765735?v=4",
491491
"profile": "https://github.com/schweden1997",
492492
"contributions": ["bug"]
493+
},
494+
{
495+
"login": "KibbeWater",
496+
"name": "Snow",
497+
"avatar_url": "https://avatars.githubusercontent.com/u/35224538?v=4",
498+
"profile": "https://kibbewater.com",
499+
"contributions": ["code", "bug"]
493500
}
494501
],
495502
"skipCi": true,

src/generate/__tests__/format-contributor.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test('format a simple contributor', () => {
2020
const {options} = fixtures()
2121

2222
const expected =
23-
'<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>'
23+
'<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>'
2424

2525
expect(formatContributor(options, contributor)).toBe(expected)
2626
})
@@ -30,7 +30,7 @@ test('format contributor with complex contribution types', () => {
3030
const {options} = fixtures()
3131

3232
const expected =
33-
'<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>'
33+
'<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>'
3434

3535
expect(formatContributor(options, contributor)).toBe(expected)
3636
})
@@ -53,7 +53,7 @@ test('default image size to 100', () => {
5353
delete options.imageSize
5454

5555
const expected =
56-
'<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>'
56+
'<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>'
5757

5858
expect(formatContributor(options, contributor)).toBe(expected)
5959
})
@@ -63,7 +63,7 @@ test('format contributor with pipes in their name', () => {
6363
const {options} = fixtures()
6464

6565
const expected =
66-
'<a href="http://github.com/chrisinajar"><img src="https://avatars1.githubusercontent.com/u/1500684?s=150" width="150px;" alt="Who &#124; Needs &#124; Pipes?"/><br /><sub><b>Who &#124; Needs &#124; Pipes?</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=pipey" title="Documentation">📖</a>'
66+
'<a href="http://github.com/chrisinajar"><img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="150px" alt="Who &#124; Needs &#124; Pipes?"/><br /><sub><b>Who &#124; Needs &#124; Pipes?</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=pipey" title="Documentation">📖</a>'
6767

6868
expect(formatContributor(options, contributor)).toBe(expected)
6969
})
@@ -73,7 +73,7 @@ test('format contributor with no GitHub account', () => {
7373
const {options} = fixtures()
7474

7575
const expected =
76-
'<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>'
76+
'<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>'
7777

7878
expect(formatContributor(options, contributor)).toBe(expected)
7979
})
@@ -83,7 +83,7 @@ test('format contributor with no complete name', () => {
8383
const {options} = fixtures()
8484

8585
const expected =
86-
'<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>'
86+
'<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>'
8787

8888
expect(formatContributor(options, contributor)).toBe(expected)
8989
})
@@ -93,6 +93,6 @@ test('format contributor with quotes in name', () => {
9393
const {options} = fixtures()
9494

9595
const expected =
96-
'<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>'
96+
'<a href="http://github.com/namelastname"><img src="https://avatars1.githubusercontent.com/u/1500684?size=150" width="150px" height="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>'
9797
expect(formatContributor(options, contributor)).toBe(expected)
9898
})

src/generate/format-contributor.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const _ = require('lodash/fp')
22
const formatContributionType = require('./format-contribution-type')
33

44
const avatarTemplate = _.template(
5-
'<img src="<%= contributor.avatar_url %>?s=<%= options.imageSize %>" width="<%= options.imageSize %>px;" alt="<%= name %>"/>',
5+
'<img src="<%= contributor.avatar_url %>" width="<%= options.imageSize %>px" height="<%= options.imageSize %>px" alt="<%= name %>"/>',
66
)
77
const avatarBlockTemplate = _.template(
88
'<a href="<%= contributor.profile %>"><%= avatar %><br /><sub><b><%= name %></b></sub></a>',
@@ -52,9 +52,19 @@ function escapeName(name) {
5252
module.exports = function formatContributor(options, contributor) {
5353
const formatter = _.partial(formatContributionType, [options, contributor])
5454
const contributions = contributor.contributions.map(formatter).join(' ')
55+
56+
const contributorAvatarUrl = new URL(contributor.avatar_url)
57+
contributorAvatarUrl.searchParams.append(
58+
'size',
59+
options.imageSize ?? defaultImageSize,
60+
)
61+
5562
const templateData = {
5663
contributions,
57-
contributor,
64+
contributor: {
65+
...contributor,
66+
avatar_url: contributorAvatarUrl.toString(),
67+
},
5868
options: _.assign({imageSize: defaultImageSize}, options),
5969
}
6070
const customTemplate =

0 commit comments

Comments
 (0)