Check that user-agent header exists before retrieving it
Showing
1 changed file
with
4 additions
and
2 deletions
... | @@ -7,9 +7,11 @@ function testUA(ua, match) { | ... | @@ -7,9 +7,11 @@ function testUA(ua, match) { |
7 | } | 7 | } |
8 | 8 | ||
9 | function fetchUA(request) { | 9 | function fetchUA(request) { |
10 | testUA(request.headers.filter(function(header) { | 10 | var headers = request.headers.filter(function(header) { |
11 | return header.name === "User-Agent"; | 11 | return header.name === "User-Agent"; |
12 | }).pop().value, /plop/); | 12 | }); |
13 | casper.test.assert(headers.length > 0); | ||
14 | testUA(headers.pop().value, /plop/); | ||
13 | } | 15 | } |
14 | 16 | ||
15 | casper.test.begin('userAgent() tests', 2, function(test) { | 17 | casper.test.begin('userAgent() tests', 2, function(test) { | ... | ... |
-
Please register or sign in to post a comment