1 | querystring = require 'querystring'
|
2 | log = require 'bog'
|
3 |
|
4 | asInt = (s) ->
|
5 | return undefined unless s
|
6 | try
|
7 | n = parseInt(s, 10)
|
8 | throw Error('nan') if isNaN(n)
|
9 | n
|
10 | catch ex
|
11 | log.warn "Failed to interpret as int: #{s}"
|
12 | undefined
|
13 |
|
14 | module.exports = (str) ->
|
15 |
|
16 | p = querystring.parse str
|
17 |
|
18 | {
|
19 | q: p.q ? ''
|
20 | }
|