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

Commit 7e51ea1

Browse files
author
Justin Ellis
committed
Actually adds the functionality that was attempted with commit 5f8a7bd. The problem with that code is that it is comparing two strings as if they are numbers, which does not work. For instance, if your jsdom.version is '0.10.1' then it will evaluate in the code as 'less than' '0.7.0', make an incorrect call to jsdom.env and nothing will work. I've added a quick and dirty, basic function to compare version number strings. It can certainly be improved upon, but should work well enough.
1 parent 9eedf8c commit 7e51ea1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/scripts/http-info.coffee

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,21 @@ module.exports = (robot) ->
5454
else if title
5555
msg.send "#{title}"
5656

57+
versionCompare = (v1, v2, comparison) ->
58+
v1parts = v1.split('.')
59+
v2parts = v2.split('.')
60+
61+
for value1, i in v1parts
62+
value1 = parseInt(value1, 10)
63+
value2 = parseInt(v2parts[i], 10)
64+
if comparison == '<' and value1 < value2
65+
return 1
66+
if comparison == '>' and value1 > value2
67+
return 1
68+
return 0
69+
5770
unless ignore
58-
if jsdom.version < '0.7.0'
71+
if versionCompare jsdom.version, '0.7.0', '<'
5972
jsdom.env
6073
html: url
6174
scripts: [ jquery ]

0 commit comments

Comments
 (0)