Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
9b3d9f51
...
9b3d9f51c2a6c3f9a62c1e1ffa839ec441a34092
authored
2011-12-20 12:55:42 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refs #29 - added Casper.setHttpAuth()in urls
1 parent
1d797e66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
lib/casper.js
lib/casper.js
View file @
9b3d9f5
...
...
@@ -581,12 +581,7 @@
// 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
.
setHttpAuth
(
httpAuthMatch
[
1
],
httpAuthMatch
[
2
]);
}
this
.
page
.
open
(
location
);
return
this
;
...
...
@@ -686,6 +681,26 @@
},
/**
* Sets HTTP authentication parameters.
*
* @param String username The HTTP_AUTH_USER value
* @param String password The HTTP_AUTH_PW value
* @return Casper
*/
setHttpAuth
:
function
(
username
,
password
)
{
if
(
!
this
.
started
)
{
throw
"Casper must be started in order to use the setHttpAuth() method"
;
}
if
(
!
isType
(
username
,
"string"
)
||
!
isType
(
password
,
"string"
))
{
throw
"Both username and password must be strings"
;
}
this
.
page
.
settings
.
userName
=
username
;
this
.
page
.
settings
.
password
=
password
;
this
.
log
(
"Setting HTTP authentication for user "
+
username
,
"info"
);
return
this
;
},
/**
* Configures and starts Casper.
*
* @param String location An optional location to open on start
...
...
Please
register
or
sign in
to post a comment