closes #29 - casper.open() can now directly handle HTTP authentication parameters in urls
Showing
1 changed file
with
10 additions
and
0 deletions
... | @@ -578,6 +578,16 @@ | ... | @@ -578,6 +578,16 @@ |
578 | open: function(location, options) { | 578 | open: function(location, options) { |
579 | options = isType(options, "object") ? options : {}; | 579 | options = isType(options, "object") ? options : {}; |
580 | this.requestUrl = location; | 580 | this.requestUrl = location; |
581 | // http auth | ||
582 | var httpAuthMatch = location.match(/^https?:\/\/(.+):(.+)@/i); | ||
583 | if (httpAuthMatch) { | ||
584 | this.page.settings.userName = httpAuthMatch[1]; | ||
585 | this.page.settings.password = httpAuthMatch[2]; | ||
586 | this.log("Adding authentication for user " + this.page.settings.userName, "info"); | ||
587 | } else { | ||
588 | delete this.page.settings.userName; | ||
589 | delete this.page.settings.password; | ||
590 | } | ||
581 | this.page.open(location); | 591 | this.page.open(location); |
582 | return this; | 592 | return this; |
583 | }, | 593 | }, | ... | ... |
-
Please register or sign in to post a comment