Skip to content

Instantly share code, notes, and snippets.

@codenamezjames
Last active February 10, 2016 05:44
Show Gist options
  • Save codenamezjames/eb4e456ba14194c8b6fd to your computer and use it in GitHub Desktop.
Save codenamezjames/eb4e456ba14194c8b6fd to your computer and use it in GitHub Desktop.
(function ($) {
$(function () {
$('.secondaryNavList a').each(function () {
function replaceBetween(str, what, start, end) {
return str.substring(0, start) + what + str.substring(end);
}
var href = $(this).attr('href');
var shouldAlter = (href.match(/\/category\//g).length > 1);
if (shouldAlter) {
var cat = href.substring(href.lastIndexOf('category/'), href.length);
href = replaceBetween(href, cat, href.indexOf('category/'), href.length);
$(this).attr('href', href);
}
});
});
}($));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment