UNPKG

553 BJavaScriptView Raw
1'use strict';
2
3const gitUrl = require('giturl');
4
5function bestGuessHomepage(data) {
6 if (!data) {
7 return false;
8 }
9
10 const packageDataForLatest = data.versions[data['dist-tags'].latest];
11
12 return packageDataForLatest.homepage ||
13 packageDataForLatest.bugs && packageDataForLatest.bugs.url && gitUrl.parse(packageDataForLatest.bugs.url.trim()) ||
14 packageDataForLatest.repository && packageDataForLatest.repository.url && gitUrl.parse(packageDataForLatest.repository.url.trim());
15}
16
17module.exports = bestGuessHomepage;