Permalink
Browse files

We should be able to detect urls anywhere in the string now

  • Loading branch information...
1 parent 7242d1d commit cce66230bae37773837d709240eb03fd11d03311 @CrazyLemon CrazyLemon committed Sep 9, 2017
Showing with 5 additions and 4 deletions.
  1. +5 −4 scripts/url.coffee
View
@@ -1,12 +1,13 @@
module.exports = (bot) ->
- is_url = /(?:^https?:\/\/|^(www\.?)).+/
+ is_url = /(((https?:\/\/)|(www\.))[^\s]+)/
resolve = (url, cb)->
if is_url.test url
- if url.substring(0,3) == "www"
- url = "http://" + url
- bot.fetchHTML url, ($)->
+ parsed_url = url.match(is_url)
+ if parsed_url[0].substring(0,3) == "www"
+ parsed_url[0] = "http://" + parsed_url[0]
+ bot.fetchHTML parsed_url[0], ($)->
if $
stack = []
stack.push $("title").eq(0).text().replace(/\s\s+/g, "").replace(/ /g,"").replace(/\n/g, "")

0 comments on commit cce6623

Please sign in to comment.