From 1c65d26ac9f10ac0037094c207d216fbf0e969bf Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Tue, 19 Nov 2019 16:32:57 -0500 Subject: fix(fund): open url for string shorthand Trying to open url for a package that is using the string shorthand is currently broken using: `npm fund ` This commit fixes the issue and adds the missing unit and integration tests covering that usecase. Fixes #498 PR-URL: https://github.com/npm/cli/pull/501 Credit: @ruyadorno Close: #501 Reviewed-by: @mikemimik --- lib/fund.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/fund.js') diff --git a/lib/fund.js b/lib/fund.js index 4981e4615..00954c844 100644 --- a/lib/fund.js +++ b/lib/fund.js @@ -14,7 +14,7 @@ const readShrinkwrap = require('./install/read-shrinkwrap.js') const mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js') const output = require('./utils/output.js') const openUrl = require('./utils/open-url.js') -const { getFundingInfo, validFundingUrl } = require('./utils/funding.js') +const { getFundingInfo, retrieveFunding, validFundingUrl } = require('./utils/funding.js') const FundConfig = figgyPudding({ browser: {}, // used by ./utils/open-url @@ -132,7 +132,7 @@ function printHuman (fundingInfo, opts) { function openFundingUrl (packageName, cb) { function getUrlAndOpen (packageMetadata) { const { funding } = packageMetadata - const { type, url } = funding || {} + const { type, url } = retrieveFunding(funding) || {} const noFundingError = new Error(`No funding method available for: ${packageName}`) noFundingError.code = 'ENOFUND' -- cgit v1.2.3