Steps to reproduce:
- Create a bookmarklet with 2 domains, in this order: www.example.org and stagewww.example.org. The first one needs to be contained in the second one.
- Go to second domain (stagewww)
- Bookmarklet thinks you are on the first one because it matches. It shows the wrong domain with an incorrect link (it will show a stagewww link, since it thinks you are on the other one, but in addition the href will point to stagestagewww.example.org because of the replacing it does)
It should not happen :-) A workaround is to simply different subdomains when you can (like wwwstage instead of stagewww).