Browse Source

Made `now cc add` case-unsensitive

This closes #631
master
Leo Lamprecht 8 years ago
parent
commit
8a603c04d8
  1. 25
      bin/now-billing-add.js

25
bin/now-billing-add.js

@ -76,13 +76,34 @@ module.exports = function({ creditCards, currentTeam, user }) {
if (!Object.hasOwnProperty.call(countries, country)) { if (!Object.hasOwnProperty.call(countries, country)) {
continue continue
} }
if (country.startsWith(value)) { if (country.startsWith(value)) {
return country.substr(value.length) return country.substr(value.length)
} }
const lowercaseCountry = country.toLowerCase()
const lowercaseValue = value.toLowerCase()
if (lowercaseCountry.startsWith(lowercaseValue)) {
return lowercaseCountry.substr(value.length)
}
} }
return false return false
}, },
validateValue: value => countries[value] !== undefined validateValue: value => {
for (const country in countries) {
if (!Object.hasOwnProperty.call(countries, country)) {
continue
}
if (country.toLowerCase() === value.toLowerCase()) {
return true
}
}
return false
}
}, },
zipCode: { zipCode: {
@ -134,11 +155,13 @@ module.exports = function({ creditCards, currentTeam, user }) {
if (key === 'cardNumber') { if (key === 'cardNumber') {
let brand = cardBrands[ccValidator.determineCardType(result)] let brand = cardBrands[ccValidator.determineCardType(result)]
piece.brand = brand piece.brand = brand
if (brand === 'American Express') { if (brand === 'American Express') {
state.ccv.placeholder = '#'.repeat(4) state.ccv.placeholder = '#'.repeat(4)
} else { } else {
state.ccv.placeholder = '#'.repeat(3) state.ccv.placeholder = '#'.repeat(3)
} }
brand = chalk.cyan(`[${brand}]`) brand = chalk.cyan(`[${brand}]`)
const masked = chalk.gray('#### '.repeat(3)) + result.split(' ')[3] const masked = chalk.gray('#### '.repeat(3)) + result.split(' ')[3]
process.stdout.write( process.stdout.write(

Loading…
Cancel
Save