Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit e63f0d5

Browse files
Stringifying the status codes to match up with the incoming match from the regex. Adding 'not found' message.
1 parent a64227f commit e63f0d5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/scripts/httpcat.coffee

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@
2020
# Author:
2121
# @commadelimited
2222

23-
codes = [100, 101, 200, 201, 202, 204, 206, 207, 300, 301, 303, 304, 305, 307, 400, 401, 402, 403, 404,
24-
405, 406, 408, 409, 410, 411, 413, 414, 416, 417, 418, 422, 423, 424, 425, 426, 429, 431, 444,
25-
450, 500, 502, 503, 506, 507, 508, 509, 599]
23+
codes = ['100', '101', '200', '201', '202', '204', '206', '207', '300', '301', '303', '304',
24+
'305', '307', '400', '401', '402', '403', '404', '405', '406', '408', '409', '410',
25+
'411', '413', '414', '416', '417', '418', '422', '423', '424', '425', '426', '429',
26+
'431', '444', '450', '500', '502', '503', '506', '507', '508', '509', '599']
2627

2728
module.exports = (robot) ->
28-
robot.respond /httpcat (\d{3})/i, (msg) ->
29-
status = msg.match[1]
30-
31-
if (codes.indexOf(status))
29+
robot.respond /httpcat (.+)/i, (msg) ->
30+
if (codes.indexOf( msg.match[1] ) > -1)
3231
msg.send 'http://httpcats.herokuapp.com/' + status + '.jpg'
3332
else
34-
msg.send 'Sorry nothing found'
33+
msg.send 'I only recognize the following status codes: ' + codes
3534

3635

3736
robot.respond /httpcat help/i, (msg) ->

0 commit comments

Comments
 (0)