Remove Parenthesis from Koha URLs with JQuery


Today’s guest post comes from Christopher Brannon at Cooperative Information Network (CIN).


We were running into issues in which Koha’s subject links with parenthesis would have no results. Removing the parenthesis from the URLs makes it work. This is the best solution I’ve found so far. Unfortunately it isn’t as straight forward as replacing the parenthesis with spaces, because some extra spaces in the URL also end up breaking the search. So, I had to get a little creative.

//Fix subject search by striping parenthesis from url links
$('#catalogue_detail_biblio a[href*="su:"]').attr('href', function(_,v){

return v.replace(/(\w)(\(|\))(\w)/g,'$1 $3')

}).attr('href', function(_,v){

return v.replace(/(\(|\))/g,'')

});
//End fix subject search

Leave a comment

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload CAPTCHA.