Skip to content

Commit

Permalink
Resolve inline urls
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyLemon authored and dz0ny committed Sep 20, 2017
1 parent c8985c4 commit 2412e4f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '6'
- '8'
dist: trusty
sudo: false
deploy:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"start": "./node_modules/.bin/coffee bot.coffee"
},
"engines": {
"node": "6.9.4"
"node": "8.5.0"
},
"repository": "",
"private": false,
Expand Down
5 changes: 2 additions & 3 deletions scripts/url.coffee
@@ -1,11 +1,10 @@
module.exports = (bot) ->

is_url = /(?:^https?:\/\/|^(www\.?)).+/
is_url = /(https?[\w:\/\.;&\?_\-\#]+)/g;

resolve = (url, cb)->
if is_url.test url
if url.substring(0,3) == "www"
url = "http://" + url
url = url.match(is_url)[0]
bot.fetchHTML url, ($)->
if $
stack = []
Expand Down
4 changes: 2 additions & 2 deletions test/url.coffee
Expand Up @@ -14,7 +14,7 @@ describe 'url.coffee', ->
done()

it 'test .nalozi veljaven url', (done)->
bot.test ".nalozi http://www.ubuntu.si/", (msg)->
bot.test ".nalozi https://www.google.si/", (msg)->
expect(msg).to.be.a('string')
expect(msg.length).to.be.at.least 2
done()
done()
4 changes: 2 additions & 2 deletions test/vreme.coffee
Expand Up @@ -28,7 +28,7 @@ describe 'vreme.coffee', ->
it 'test .vreme lj', (done)->
bot.test ".vreme lj", (msg)->
expect(msg).to.be.a('string')
expect(msg.length).to.be.at.least 20
expect(msg.length).to.be.at.least 16
done()

it 'test .vreme katarina pri ljubljani (oblacnost ter vremenski pojav pa brez vetra)', (done)->
Expand All @@ -39,7 +39,7 @@ describe 'vreme.coffee', ->
it 'test .vreme new york', (done)->
bot.test ".vreme new york", (msg)->
expect(msg).to.be.a('string')
expect(msg.length).to.be.at.least 20
expect(msg.length).to.be.at.least 16
done()

it 'test .radar', (done)->
Expand Down

0 comments on commit 2412e4f

Please sign in to comment.