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

SS5: add trailing slash config and redirect #10538

Conversation

xini
Copy link
Contributor

@xini xini commented Oct 10, 2022

This PR adds trailing slash configuration to Controller and extends CanonicalURLMiddleware to include the trailing slash redirect.

This covers criteria 2-4 of the parent issue

Parent issue

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

I haven't actually tested this yet but here's some preliminary changes to make

src/Control/Director.php Outdated Show resolved Hide resolved
src/Control/Controller.php Outdated Show resolved Hide resolved
src/Control/Middleware/CanonicalURLMiddleware.php Outdated Show resolved Hide resolved
src/Control/Middleware/CanonicalURLMiddleware.php Outdated Show resolved Hide resolved
src/Control/Middleware/CanonicalURLMiddleware.php Outdated Show resolved Hide resolved
src/Control/Middleware/CanonicalURLMiddleware.php Outdated Show resolved Hide resolved
src/Control/Controller.php Outdated Show resolved Hide resolved
src/Control/Controller.php Outdated Show resolved Hide resolved
src/Control/Controller.php Outdated Show resolved Hide resolved
src/Control/Director.php Outdated Show resolved Hide resolved
@GuySartorelli GuySartorelli force-pushed the feature-5-trailing-slash-config-and-redirect branch from ab5ab7d to 65641ef Compare January 12, 2023 02:28
@GuySartorelli
Copy link
Member

Rebased, fixed issues, and squashed commits. I'm also going to mark this as a DRAFT until I have the related PRs fixed up and ready to go.

* If set, the trailing slash configuration set in {@link Controller::add_trailing_slash} is enforced
* with a redirect.
*/
protected bool $forceTrailingSlash = true;
Copy link
Member

@emteknetnz emteknetnz Jan 18, 2023

Choose a reason for hiding this comment

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

This is a badly named property (along with all the other "forceTrailingSlash*" properties.) It does not "force trailing slash" - instead it is basically "do not ignore the trailing slash config on Controller". The naming here makes this very confusing

We'll need to rename this, perhaps simply to "respectTrailingSlashConfig*"? Though there's probably something more better and more concise that would be used. Another option would be to rename this to "ignoreTrailingSlashConfig*" and then reverse the logic

Copy link
Member

Choose a reason for hiding this comment

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

How about redirectWithTrailingSlashConfig? A bit verbose but it makes it clear, I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm. You're right it's not forcing the trailing slash, but rather its config value. The correct name would then be "forceTrailingSlashConfig"?

Copy link
Member

Choose a reason for hiding this comment

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

I think 'force' is probably the wrong word here, though I think just 'enforce' works fine

So this would become enforceTrailingSlashConfig

Does that sound alright?

NOTE: There will be additional related PRs required for at least
silverstripe/cms and silverstripe/admin.

Co-authored-by: Guy Sartorelli <[email protected]>
@GuySartorelli GuySartorelli force-pushed the feature-5-trailing-slash-config-and-redirect branch from deb5d20 to fbcf7dc Compare January 19, 2023 21:31
@GuySartorelli GuySartorelli dismissed their stale review January 19, 2023 21:32

Those changes were done

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

Successfully merging this pull request may close these issues.

3 participants