11cb0ef41Sopenharmony_ciconst PackageUrlCmd = require('../package-url-cmd.js')
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciclass Bugs extends PackageUrlCmd {
41cb0ef41Sopenharmony_ci  static description = 'Report bugs for a package in a web browser'
51cb0ef41Sopenharmony_ci  static name = 'bugs'
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci  getUrl (spec, mani) {
81cb0ef41Sopenharmony_ci    if (mani.bugs) {
91cb0ef41Sopenharmony_ci      if (typeof mani.bugs === 'string') {
101cb0ef41Sopenharmony_ci        return mani.bugs
111cb0ef41Sopenharmony_ci      }
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci      if (typeof mani.bugs === 'object' && mani.bugs.url) {
141cb0ef41Sopenharmony_ci        return mani.bugs.url
151cb0ef41Sopenharmony_ci      }
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci      if (typeof mani.bugs === 'object' && mani.bugs.email) {
181cb0ef41Sopenharmony_ci        return `mailto:${mani.bugs.email}`
191cb0ef41Sopenharmony_ci      }
201cb0ef41Sopenharmony_ci    }
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci    // try to get it from the repo, if possible
231cb0ef41Sopenharmony_ci    const info = this.hostedFromMani(mani)
241cb0ef41Sopenharmony_ci    const infoUrl = info?.bugs()
251cb0ef41Sopenharmony_ci    if (infoUrl) {
261cb0ef41Sopenharmony_ci      return infoUrl
271cb0ef41Sopenharmony_ci    }
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci    // just send them to the website, hopefully that has some info!
301cb0ef41Sopenharmony_ci    return `https://www.npmjs.com/package/${mani.name}`
311cb0ef41Sopenharmony_ci  }
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_cimodule.exports = Bugs
35