Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Fix npm repo error for unnormalized shorthand urls
Browse files Browse the repository at this point in the history
New npm versions are supporting the shorthand username/repo
in the repository field of the package.json - but sometimes
people with old npm versions are publishing them and they
do not get normalized.

Fixes #3952
  • Loading branch information
robertkowalski authored and isaacs committed Oct 24, 2013
1 parent cdaed24 commit e790ae9
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 3 deletions.
10 changes: 9 additions & 1 deletion lib/repo.js
Expand Up @@ -15,6 +15,7 @@ var npm = require("./npm.js")
, log = require("npmlog")
, opener = require("opener")
, github = require('github-url-from-git')
, githubUserRepo = require("github-url-from-username-repo")

function repo (args, cb) {
if (!args.length) return cb(repo.usage)
Expand All @@ -23,7 +24,14 @@ function repo (args, cb) {
if (er) return cb(er)
var r = d.repository;
if (!r) return cb(new Error('no repository'));
var url = github(r.url);
// XXX remove this when npm@v1.3.10 from node 0.10 is deprecated
// from https://github.com/isaacs/npm-www/issues/418
if (githubUserRepo(r.url))
r.url = githubUserRepo(r.url)

var url = github(r.url)
if (!url)
return cb(new Error('no repository: could not get url'))
opener(url, { command: npm.config.get("browser") }, cb)
})
}
13 changes: 13 additions & 0 deletions node_modules/github-url-from-username-repo/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions node_modules/github-url-from-username-repo/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions node_modules/github-url-from-username-repo/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions node_modules/github-url-from-username-repo/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/github-url-from-username-repo/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions node_modules/github-url-from-username-repo/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/github-url-from-username-repo/test/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -74,7 +74,8 @@
"editor": "0.0.5",
"child-process-close": "~0.1.1",
"npm-user-validate": "0.0.3",
"github-url-from-git": "1.1.1"
"github-url-from-git": "1.1.1",
"github-url-from-username-repo": "0.0.2"
},
"bundleDependencies": [
"semver",
Expand Down Expand Up @@ -118,7 +119,8 @@
"child-process-close",
"editor",
"npm-user-validate",
"github-url-from-git"
"github-url-from-git",
"github-url-from-username-repo"
],
"devDependencies": {
"ronn": "~0.3.6",
Expand Down

0 comments on commit e790ae9

Please sign in to comment.