Attached is a patch. It appears to work, but I'm not sure whether the anchor should be applied all portlet urls or just certain ones?
I have also adjusted the test code to expect the new url when configured.
Fixed, with a slight modification. Since portlet action URLs always result in a 302 redirect anchors will only be added to render URLs. Functionally the patch is the same after this modification.