Permalink
Browse files

Resolve inline urls

  • Loading branch information...
1 parent c8985c4 commit 2412e4ffc63ffc6b4e5d540b45818733460868de @CrazyLemon CrazyLemon committed with dz0ny Sep 8, 2017
Showing with 8 additions and 9 deletions.
  1. +1 −1 .travis.yml
  2. +1 −1 package.json
  3. +2 −3 scripts/url.coffee
  4. +2 −2 test/url.coffee
  5. +2 −2 test/vreme.coffee
View
@@ -1,6 +1,6 @@
language: node_js
node_js:
-- '6'
+- '8'
dist: trusty
sudo: false
deploy:
View
@@ -8,7 +8,7 @@
"start": "./node_modules/.bin/coffee bot.coffee"
},
"engines": {
- "node": "6.9.4"
+ "node": "8.5.0"
},
"repository": "",
"private": false,
View
@@ -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 = []
View
@@ -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()
View
@@ -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)->
@@ -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)->

0 comments on commit 2412e4f

Please sign in to comment.