By the question above, I guess that hardcoding the url exactly like it should be and pass it to the sharer api is not an option.
The problem:
As you may have noticed, facebook (and g+ also) will not accept the '&' character as well as anything that follows that.
So we should find a way to decode ONLY this '&'.
If you use encodeURIComponent then, all you url's special characters will be transformed to '%xx' style.
I.E.
var url_enc = encodeURIComponent('http://myhome.com?q=hi&there');
alert(url_enc);
will output this: http%3A%2F%2Fmyhome.com%3Fq%3Dhi%26there
which is not accepted by sharer either!
As I wrote before, what is really needed here is to send a url like this:
http://myhome.com?q=hi%26there
which is accepted by facebook api.
Solution:
If you can't send the url as it is, and it maybe needs to be passed through a library that creates sharers and does the job for you, you need to pass exactly the url as it should be and then combine encodeURI and decodeURIComponent like below. (Personally i had to make this correction in order to work fine, so it was a serious bug)
In the following example, i assume that a javascript library is used.
var url = 'http://myhome.com?q=hi%26there';
library_function_that_creates_sharer(some_variable, url);
and then, inside that function, encode and decode to keep the url exactly the same.
decodeURIComponent(encodeURI(url));
In other words:
var url_new = decodeURIComponent(encodeURI(url));
ends up to be url_new = url
.