-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fixing issue #319 #320
Fixing issue #319 #320
Conversation
@stof what do you think about this PR? |
As you can see in the tests, you completely change the behavior of the router in some cases. Please make sure you only add new functionality without changing the current behavior. Could you provide some tests with a changed port as well? |
Port extension test added, all tests are up and running! |
|
@emulienfou actually I made a mistake in my previous tests and it was using a cached response for the route export. I just tested it again and actually this fix does not work for me. For generated routes it does not correctly append the port for me. Maybe its because I use multiple hosts and have host restrictions on the routes that I tested? If I use |
Hi @dmaicher, just to be sure, here whats in my {
"base_url":"",
"routes":{
"projectharmony_message_new":{
"tokens":[
[
"text",
"\/messages\/new"
]
],
"defaults":[
],
"requirements":[
],
"hosttokens":[
[
"text",
"account.harmonycms.net"
]
],
"methods":[
],
"schemes":[
]
},
},
"prefix":"",
"host":"localhost:8082",
"portextension":":8082",
"scheme":"http"
} Do you have the Do you think port is missing in the Actually my modifications is working perfectly in my app, using FOSMessageBundle and others!!! |
example:
So now I am on
Now gives me: With the PR #185 I get |
So weird, I got the same fix but not the same output. In your composer.lock you are using the commit Because I get the url, by example http://marketplace.harmonycms.net::8082/vote/1/theme when generating the route like you do! |
@emulienfou yes I'm using that commit. But the two fixes are clearly different here: 😉 That's the issue for me. |
Append color `:` only when *host + port* are used in JS and Extractor
@tobias-93 Issue fixed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works now 👍
small comments on how to simplify it
Extractor/ExposedRoutesExtractor.php
Outdated
@@ -104,14 +104,26 @@ public function getHost() | |||
{ | |||
$requestContext = $this->router->getContext(); | |||
|
|||
$host = $requestContext->getHost(); | |||
$host = $requestContext->getHost() . | |||
('' === $this->getPortExtension() ? $this->getPortExtension() : ':' . $this->getPortExtension()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the colon should be added here instead I believe
Like it was done here also:
Otherwise this comment is wrong: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/320/files#diff-1955b791bdfe6c6e2f87f9dd89d24413R53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remove the colon :
because the tests are wrong.
- For me,
portextension
should only contain port number without colon. - In the JS test case , we need to test with
portextension: ':443'
instead ofportextension: 443
- And yes, I think the comment is wrong and need to be changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called portExtension then? can be just port
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good question.
This came from the PR #185
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I can rename portExtension
by port
. I think, like you said, everyone will know what it is ?
Resources/js/router.js
Outdated
@@ -263,8 +281,8 @@ class Router { | |||
url = route.requirements["_scheme"] + "://" + (host || this.getHost()) + url; | |||
} else if ("undefined" !== typeof route.schemes && "undefined" !== typeof route.schemes[0] && this.getScheme() !== route.schemes[0]) { | |||
url = route.schemes[0] + "://" + (host || this.getHost()) + url; | |||
} else if (host && this.getHost() !== host) { | |||
url = this.getScheme() + "://" + host + url; | |||
} else if (host && this.getHost() !== host + ('' === portextension ? '' : ':' + portextension)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can then just be like here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of code has been changed, because I remove the colon :
in the portextension
variable.
Like I said before, the portextension
variable should only contain an int value with the port number
can you check if you can make the tests pass on PHP 5.6? |
@lsmith77 did we deprecate PHP 5.3 too from |
Any progress on getting this merged? |
not using the Bundle but took the “risk” of merging it since it looks good and the tests pass. |
@lsmith77 Thanks, are you going to make a release so i can update my composer without pinning it to the dev-master? |
Fixing issue #319.
Based from the PR #185 by @chandon this fix has been ported to Symfony 4 and tested by myself!