Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
Created November 19, 2014 10:10
Show Gist options
  • Save kalinchernev/d05691e84af67c594856 to your computer and use it in GitHub Desktop.
Save kalinchernev/d05691e84af67c594856 to your computer and use it in GitHub Desktop.
Function to replace development and production urls
// development is a string containing the domain base of the dev site
// production is a string containing the domain base of the production site
function replaceDomains(development,production){
var links = jQuery("a");
for (var i = 0; i < links.length; i++) {
var href = jQuery(links[i]).attr("href");
if ((href !== undefined) && (href.indexOf(production) > -1)) {
href = href.replace(production, development);
jQuery(links[i]).attr("href", href);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment