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

Commit a9b48f5

Browse files
Merge pull request #1270 from spajus/patch-2
Make http-info.coffee work with latest jsdom
2 parents 94965a9 + 5f8a7bd commit a9b48f5

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

src/scripts/http-info.coffee

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Returns title and description when links are posted
33
#
44
# Dependencies:
5-
# "jsdom": "0.2.15"
5+
# "jsdom": "0.8.10"
66
# "underscore": "1.3.3"
77
#
88
# Configuration:
@@ -40,21 +40,28 @@ module.exports = (robot) ->
4040
if !ignore && ignorePattern
4141
ignore = url.match(ignorePattern)
4242

43+
jquery = 'http://code.jquery.com/jquery-1.9.1.min.js'
44+
45+
done = (errors, window) ->
46+
unless errors
47+
$ = window.$
48+
title = $('title').text()
49+
description = $('meta[name=description]').attr("content") || ""
50+
51+
if title and description and not process.env.HUBOT_HTTP_INFO_IGNORE_DESC
52+
msg.send "#{title}\n#{description}"
53+
54+
else if title
55+
msg.send "#{title}"
56+
4357
unless ignore
44-
jsdom.env(
45-
html: url
46-
scripts: [
47-
'http://code.jquery.com/jquery-1.9.1.min.js'
48-
]
49-
done: (errors, window) ->
50-
unless errors
51-
$ = window.$
52-
title = $('title').text()
53-
description = $('meta[name=description]').attr("content") || ""
54-
55-
if title and description and not process.env.HUBOT_HTTP_INFO_IGNORE_DESC
56-
msg.send "#{title}\n#{description}"
57-
58-
else if title
59-
msg.send "#{title}"
60-
)
58+
if jsdom.version < '0.7.0'
59+
jsdom.env
60+
html: url
61+
scripts: [ jquery ]
62+
done: done
63+
else
64+
jsdom.env
65+
url: url
66+
scripts: [ jquery ]
67+
done: done

0 commit comments

Comments
 (0)