Clean trailing characters like . from host
It was noticed in https://gitlab.com/gitlab-org/gitlab-pages/-/issues/690#note_963805488 that there are certain requests with trailing . which causes a failure in exact domain host name matching while querying the gitlab api.
We should redirect request with trailing . after stripping them of ..
Note: Trailing . in domains have special significance . But it looks like it wouldn't affect us in this case.
Update
- Since trailing
.in domains have special significance, if we strip.in the domain and redirect, a suffix would get added through the DNS resolution at the client side - E.g. the client has a DNS suffix configured(
suffix.). When they typexyz.test, it gets resolved toxyz.test.suffix.. Thus, if we redirect,xyz.test.toxyz.test, the client would resolve it toxyz.test.suffix.. And it could lead to a redirection loop as well. - Keeping the above in mind, we should rewrite the request in place and just strip off the trailing
.by adding a middleware which would normalize the host name of the request.
Edited by Vishal Tak