Commit 1d797e66 1d797e668da0a1279656ca0221559d99eecb4e45 by Nicolas Perriault

closes #29 - casper.open() can now directly handle HTTP authentication parameters in urls

1 parent 963d1a3b
...@@ -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 },
......