Skip to content

Fix non-http prepended urls - #35

Merged
kentcdodds merged 4 commits into
all-contributors:masterfrom
alexjoverm:master
Feb 23, 2017
Merged

kentcdodds merged 4 commits into
all-contributors:masterfrom
alexjoverm:master

Conversation

@alexjoverm

Copy link
Copy Markdown
Contributor

When either body.blog || body.html_url are not prepended with http, github itself does it for you. But when those are retrieved from the url, they still come without the http://, causing the link to be broken.

See this PR from one of my repos for more info: alexjoverm/typescript-library-starter#7

Additionally, I made this PR from windows and was finding a lot of CLRF issues, so I've added a .editorconfig thus that doesn't happen to other people.

@kentcdodds kentcdodds left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Just a few changes. Thanks!

Comment thread .editorconfig Outdated
@@ -0,0 +1,16 @@
#root = true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this. I prefer to not have unrelated changes in PRs. Feel free to make another PR if you want to add this.

Comment thread lib/contributors/github.js Outdated
name: body.name || username,
avatar_url: body.avatar_url,
profile: body.blog || body.html_url
profile: profile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We support Node v4 and above so you can use object shorthand here:

{
  // ...
  profile
  // ...
}

});
});

test('should append http when no absolute link is provided', t => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@alexjoverm

Copy link
Copy Markdown
Contributor Author

@kentcdodds I've also realized I could use startsWith instead of indexOf :)

@kentcdodds
kentcdodds merged commit a879de2 into all-contributors:master Feb 23, 2017
@kentcdodds

Copy link
Copy Markdown
Member

Thanks a bunch!

@jfmengels

Copy link
Copy Markdown
Collaborator

Thanks a lot @alexjoverm! 🎉

Berkmann18 pushed a commit that referenced this pull request May 24, 2020
* docs: update README.md

* docs: update .all-contributorsrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants