Skip to content

Commit

Permalink
fix: ensure profile URLs have protocol (#77)
Browse files Browse the repository at this point in the history
* fix: ensure profile URLs have protocol

* test: fix
  • Loading branch information
jakebolam authored Jan 21, 2019
1 parent 04a4612 commit f38260b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/OptionsConfig/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ class OptionsConfig {
}

async addContributor({ login, contributions, name, avatar_url, profile }) {
const profileWithProtocol = profile.startsWith('http')
? profile
: `http://${profile}`

const newContributorsList = await addContributorWithDetails({
options: this.options,
login,
contributions,
name,
avatar_url,
profile,
profile: profileWithProtocol,
})
const newOptions = {
...this.options,
Expand Down
27 changes: 27 additions & 0 deletions test/OptionsConfig/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ describe('ContentFiles', () => {
})
})

test(`If profile URL is missing protocol, add it for them`, async () => {
const optionsConfig = new OptionsConfig({
repository: mockRepository,
commentReply: mockCommentReply,
})
optionsConfig.init()

await optionsConfig.addContributor({
login: 'jakebolam',
contributions: ['ideas'],
name: 'Jake Bolam',
avatar_url: 'https://avatars2.githubusercontent.com/u/3534236?v=4',
profile: 'jakebolam.com',
})

expect(optionsConfig.options.contributors).toEqual([
{
login: 'jakebolam',
name: 'Jake Bolam',
avatar_url:
'https://avatars2.githubusercontent.com/u/3534236?v=4',
profile: 'http://jakebolam.com',
contributions: ['ideas'],
},
])
})

test(`Inits the contributor file`, () => {
const optionsConfig = new OptionsConfig({
repository: mockRepository,
Expand Down

0 comments on commit f38260b

Please sign in to comment.