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 @@
open: function(location, options) {
options = isType(options, "object") ? options : {};
this.requestUrl = location;
// http auth
var httpAuthMatch = location.match(/^https?:\/\/(.+):(.+)@/i);
if (httpAuthMatch) {
this.page.settings.userName = httpAuthMatch[1];
this.page.settings.password = httpAuthMatch[2];
this.log("Adding authentication for user " + this.page.settings.userName, "info");
} else {
delete this.page.settings.userName;
delete this.page.settings.password;
}
this.page.open(location);
return this;
},
......