Fix generating URLs for JavaScript (Bug #12572).