Get normalized repository URL from package json data
People write the repository URL in their
package.json file using different formats, and sometimes there is even a typo.
This module extracts the code from the npm package manager, and uses normalize-package-data, hosted-git-info and parse-github-repo-url, to parse the provided package input and return a repository URL object.
If you are interested, please check those other packages for more details.
Common misspelling of the repository field are also corrected (Please see the source code for available corrections.).
This module mutates/normalizes the input using
If you find the returned repository URL object is not correct, it's likely an issue with one of the libraries listed earlier. Please try to triage the problem before you open an issue here.
$ npm install --save get-pkg-repo
var fs = ;var getPkgRepo = ;fs
hosted-git-info returned object if it matches a git host. If not, it returns a
url.parse object with a
browse function which returns the url that can be browsed.
Should be the contents of a
pkgData are mutated/normalized by
If you want to fix your typical typos automatically pass
Please keep in mind that this feature may be removed in the future. The
package.jsonis well documented and it should be correctly spelled.
$ npm install --global get-pkg-repo
You can use cli to see what your url will look like after being parsed.
You can enter interactive mode by typing
You can also validate the repository url in your package.json by using the command followed by a package.json path. You can specify more than one path at a time.
$ get-pkg-repo package.json
MIT © Steve Mao