← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gmb/launchpad/fix-fragile-link-bug-741645 into lp:launchpad

 

Graham Binns has proposed merging lp:~gmb/launchpad/fix-fragile-link-bug-741645 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #741645 in Launchpad itself: "AJAX muting and unmuting broken on some projects"
  https://bugs.launchpad.net/launchpad/+bug/741645

For more details, see:
https://code.launchpad.net/~gmb/launchpad/fix-fragile-link-bug-741645/+merge/54698

This branch fixes some fragility in the updating of the mute link href on the BugTask:+index page. The problem was that we replaced all instances of '+subscribe' with '+mute' (or vice versa). The simple fix for this is to switch out the string we're replacing with a regex looking for only the last instance of that string.
-- 
https://code.launchpad.net/~gmb/launchpad/fix-fragile-link-bug-741645/+merge/54698
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/fix-fragile-link-bug-741645 into lp:launchpad.
=== modified file 'lib/lp/bugs/javascript/bugtask_index_portlets.js'
--- lib/lp/bugs/javascript/bugtask_index_portlets.js	2011-03-21 11:42:33 +0000
+++ lib/lp/bugs/javascript/bugtask_index_portlets.js	2011-03-24 13:44:27 +0000
@@ -278,7 +278,6 @@
     if (LP.links.me === undefined) {
         return;
     }
-
     var mute_subscription = get_mute_subscription();
     var mute_link = mute_subscription.get('link');
     var parent_node = mute_link.get('parentNode');
@@ -310,14 +309,14 @@
         parent_node.addClass('muted-true');
         mute_link.setAttribute(
             'href', mute_link.getAttribute('href').replace(
-                '+mute', '+subscribe'));
+                /\+mute$/, '+subscribe'));
         mute_subscription.disable_spinner("Unmute bug mail");
     } else {
         parent_node.removeClass('muted-true');
         parent_node.addClass('muted-false');
         mute_link.setAttribute(
             'href', mute_link.getAttribute('href').replace(
-                '+subscribe', '+mute'));
+                /\+subscribe$/, '+mute'));
         mute_subscription.disable_spinner("Mute bug mail");
     }
 }