SyntaxHighlighter

Monday, July 29, 2013

A Bookmarklet for switching between localhost and production

If you are often going between production and localhost:3000 - you can easily change the domain name with a simple javascriptlet - something like this...

javascript:a=document.location.href.match(/http:\/\/([^\/]+)\/(.+)/);if(a[1].match(%22exampledomain%22)){document.location=%22http://localhost:3000/%22%20+%20a[2]}else{document.location=%22http://www.exampledomain.com/%22%20+%20a[2]}

 Make this the content of a bookmark, and add it to your bookmark menu.  Easy flipping.

Adjust further if you need to go between a staging environment or another localhost domain.

1 comment:

  1. Succeed! It could be one of the most useful blogs we have ever come across on the subject. Excellent info! I’m also an expert in this topic so I can understand your effort very well. Thanks for the huge help. erkl√§rvideo

    ReplyDelete