Skip to content

Commit

Permalink
refactor: remove repository key typo fixing
Browse files Browse the repository at this point in the history
Remove support for handling the `repository` key being incorrectly
spelled in the package data object.

BREAKING CHANGE:

Typos for the `repository` key in package data will no longer be
corrected. For example, if the `repository` key is listed under the
`repo`, or `repositories`, name it will no longer be coerced into
`repository` prior to being processed by this package.

Closes #18
  • Loading branch information
hutson committed Oct 16, 2018
1 parent 3b98abb commit 30b3664
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
11 changes: 1 addition & 10 deletions index.js
Expand Up @@ -3,7 +3,6 @@ var parseSlug = require('parse-github-repo-url');
var normalizeData = require('normalize-package-data');
var hostedGitInfo = require('hosted-git-info');
var url = require('url');
var typos = ['repostitory', 'repostitorys', 'repositories', 'repostitories', 'repositorys', 'repo', 'repos'];

var gitAt = /^git@/;

Expand Down Expand Up @@ -58,19 +57,11 @@ function unknownHostedInfo(repoUrl) {
return new UnknownGitHost();
}

function getPkgRepo(pkgData, fixTypo) {
function getPkgRepo(pkgData) {
try {
pkgData = JSON.parse(pkgData);
} catch (err) {}

if (fixTypo && !pkgData.repository) {
typos.forEach(function(val) {
if (pkgData[val]) {
pkgData.repository = pkgData[val];
return false;
}
});
}
normalizeData(pkgData);

var repo = pkgData.repository;
Expand Down
11 changes: 0 additions & 11 deletions test.js
Expand Up @@ -128,17 +128,6 @@ it('should work with a json', function() {
});
});

it('should work if there is a typo', function() {
var repo = getPkgRepo({repo: 'a/b'}, true);
assertRepo(repo, {
browse: 'https://github.com/a/b',
domain: 'github.com',
type: 'github',
user: 'a',
project: 'b'
});
});

it('should error if cannot get repository', function() {
assert.throws(function() {
getPkgRepo({});
Expand Down

0 comments on commit 30b3664

Please sign in to comment.