FriendsOfSymfony/FOSJsRoutingBundle — pull request #173 by chandon (2014-12-22 17:29:43+00:00)
Title: Add HTTP non standard port support for route with specific host

To reproduce the bug before fixing it :
1) have a server on a non standard port (for example 81 instead of 80)
2) have a route with a specific host parameter in routing.yml

route_example:
path: /example
defaults: { _controller: ExampleBundle:Example:index }
host: test.example.com

3) generate a full path route using Symfony

$this->generateUrl('route_example', array(), true);

Ok, we have http://test.example.com:81/example

4) generate a full path using FOSJsRoutingBundle

We got http://test.example.com/example => the 81 port is missing !
And even if you try to generate a relative path, you'll get a full path because FOSJsRoutingBundle compare the host "test.example.com" with this.getHost() "test.example.com:81", and because it's not equals, it generates a full path... see routing.js line 242 :

} else if (host && this.getHost() !== host) {