Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "getRepositoryUrl" in order to support repository package.json property as object #204

Merged
merged 11 commits into from
Mar 11, 2016

Conversation

mattiaerre
Copy link
Member

Description

As per the npm documentation https://docs.npmjs.com/files/package.json#repository the repository property inside the package.json file should be an object like the following:

{ "type": "git", "url": "https://github.com/npm/npm.git" }

I added a getRepositoryUrl method against the component object that returns:

  • the content of the url property if repository is of type object
  • the content of the repository property itself if repository is of type string (for backwards compatibility)
  • null otherwise

then in the view (the partial .jade file) the above method is used instead of the property itself.



component.getRepositoryUrl = function() {
if (typeof this.repository === 'object') {
Copy link
Member

Choose a reason for hiding this comment

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

can we just use underscore's _.isObject for consistency?

@matteofigus
Copy link
Member

Grazie, looks good.

Would you mind adding those 2 little adjustments + adding yourself as contributor?

matteofigus added a commit that referenced this pull request Mar 11, 2016
add "getRepositoryUrl" in order to support repository package.json property as object
@matteofigus matteofigus merged commit 4febdbe into opencomponents:master Mar 11, 2016
@matteofigus
Copy link
Member

Thanks good stuff!

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.

2 participants