Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cookbook] Add annotations block and fix regex #6124

Closed
wants to merge 1 commit into from
Closed

Conversation

petk
Copy link
Contributor

@petk petk commented Jan 10, 2016

Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets N/A

@javiereguiluz
Copy link
Member

👍 thanks for this improvement @peterkokot (I find the code of the removeTrailingSlashAction() method too "complex" for this trivial case ... but I can't come up with a better proposal).


$url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri);

return $this->redirect($url, 301);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have the complete code above the configurations so I would reduce this to the bare minimum like this:

.. configuration-block::

    .. code-block:: php+annotations::

        // src/AppBundle/Controller/RedirectingController.php

        /**
         * @Route("/{url}", name="remove_trailing_slash",
         *     requirements={"url" = ".*\/$"}, methods={"GET"})
         */
        public function removeTrailingSlashAction(Request $request)
        {
            // ...
        }

@xabbuh
Copy link
Member

xabbuh commented Jan 11, 2016

Do we really need to escape the slash?

wouterj added a commit that referenced this pull request Feb 6, 2016
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #6124).

Discussion
----------

[cookbook] Add annotations block and fix regex

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | N/A

Commits
-------

10e6b30 Add annotations block and fix regex for redirecting URLs with trailing slash
wouterj added a commit that referenced this pull request Feb 6, 2016
@wouterj
Copy link
Member

wouterj commented Feb 6, 2016

Thank you @peterkokot! I've merged your PR into 2.3.

It turns out the slash doesn't have to be escaped in the regex, so I reverted that change in d3744cb (I kept it for the annotations, as it's required there).

@wouterj wouterj closed this Feb 6, 2016
@taylankasap
Copy link

How are you supposed to

put this route last in your system

when used with annotations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants