Proper escape urls
This commit is contained in:
parent
df68dd1e60
commit
d203174912
@ -30,6 +30,7 @@
|
||||
"hubot-tg": "rnhmjoj/hubot-tg",
|
||||
"hubot-youtube": "^0.1.2",
|
||||
"moment": "^2.10.2",
|
||||
"needle": "^0.10.0",
|
||||
"nightmare": "^1.8.0",
|
||||
"nock": "^1.7.1",
|
||||
"nodepie": "^0.6.7",
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Dependencies:
|
||||
# valid-url
|
||||
# needle
|
||||
#
|
||||
# Configuration:
|
||||
# None
|
||||
@ -14,6 +15,7 @@
|
||||
# Michele Guerini Rocco (rnhmjoj)
|
||||
#
|
||||
|
||||
ne = require 'needle'
|
||||
{ is_web_uri } = require 'valid-url'
|
||||
|
||||
valid = ['eccoti: ', 'ecco qui: ', 'fatto: ', '']
|
||||
@ -22,10 +24,8 @@ invalid = ['eh?', "cos'è sta roba?", 'sarebbe un url questo?']
|
||||
module.exports = (robot) ->
|
||||
robot.respond /breve|accorcia (.+)$/i, (res) ->
|
||||
url = res.match[1]
|
||||
if is_web_uri url
|
||||
robot.http('https://breve.xyz/api')
|
||||
.header('Content-Type','application/x-www-form-urlencoded')
|
||||
.post("url=#{url}") (err, r, body) ->
|
||||
res.send (res.random valid) + (JSON.parse body).link
|
||||
if is_web_uri url
|
||||
ne.post 'https://breve.xyz/api', url: url, (err, resp, body) =>
|
||||
res.send (res.random valid) + body.link
|
||||
else
|
||||
res.send res.random invalid
|
Loading…
Reference in New Issue
Block a user