in our company's application we send out an email asking users to confirm their new membership application by clicking on a link:
http://prod.mycompany.com/MembershipApplication/validateMembershipApplication?id=9354&email=me@example.com
but when i'm testing this usecase in sahi, i don't want to click on a production link, i want to use a link on my test server:
http://localhost/MembershipApplication/validateMembershipApplication?id=9354&email=me@example.com
so here's how i replace the prod link with localhost:
#######################
var $prod_url;
// ... more code ...
_set($prod_url, _link(/http:\/\/prod\.mycompany\.com\/MembershipApplication\/validateMembershipApplication\?id=.*/).href);
_call(window.open($prod_url.split("http://prod.mycompany.com").join("http://localhost")));
#######################
this code identifies a link that matches the regex below and returns the url ( .href ):
_link(/http:\/\/prod\.mycompany\.com\/MembershipApplication\/validateMembershipApplication\?id=.*/).href
thanks to the post Javascript - how to replace a sub-string? for the replace code :)
No comments:
Post a Comment