Skip to content

Commit

Permalink
fix(urban): fix args
Browse files Browse the repository at this point in the history
Fix incorrect argument parsing
  • Loading branch information
drawnepicenter committed Jun 24, 2016
1 parent b656aaf commit 59877f8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bin/cmds/urban.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions build/cmds/urban.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions src/cmds/urban.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ exports.handler = (argv) => {
if (config.merge) config = _.merge({}, config, userConfig)
const theme = themes.loadTheme(config.theme)
if (config.verbose) themes.labelDown('Urban Dictionary', theme, null)
const words = argv._.slice(1)
let query = ''
if (words.length > 1) {
query = words.join(' ')
} else { query = words[0] }
let url = `http://api.urbandictionary.com/v0/define?term=${query}`
const ucont = []
ucont.push(argv.query)
if (argv._.length > 1) {
for (let i = 1; i <= argv._.length - 1; i++) {
ucont.push(argv._[i])
}
}
let words = ''
if (ucont.length > 1) {
words = ucont.join('+')
} else {
words = ucont[0]
}
let url = `http://api.urbandictionary.com/v0/define?term=${words}`
url = encodeURI(url)
const tofile = { type: 'urban', source: 'http://www.urbandictionary.com' }
needle.get(url, (error, response) => {
Expand Down

0 comments on commit 59877f8

Please sign in to comment.