Add the /g global flag, so all occourances of the '#' get replaced with ...

...the encoded %23' value. Closes #1961
shouldn't it be `.replace(/#/g, '%23');`