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

ENH Allow URLs without trailing slashes #253

Merged

Conversation

GuySartorelli
Copy link
Member

silverstripe/silverstripe-framework#10538 allows us to have a URLs which can be configured to have or omit trailing slashes. This PR updates the campaign-admin javascript to stop explicitly expecting one to be/not be there.

Note that this PR will need to be modified once silverstripe/webpack-config#57 has been merged and released in NPM.

Parent issue


// Set root breadcrumb
const breadcrumbs = [{
text: i18n._t('CampaignAdmin.CAMPAIGN', 'Campaigns'),
href: url,
href: `/${reactRoutePath}`,
Copy link
Member

Choose a reason for hiding this comment

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

Can we always guarantee that reactRoutePath won't have a leading slash?

Copy link
Member Author

@GuySartorelli GuySartorelli Jan 19, 2023

Choose a reason for hiding this comment

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

Theoretically yes but realistically there's the remote chance someone will do something really weird lol. I'll apply joinUrlPaths to it as you recommended in another comment, that's a really elegant way to handle it that I hadn't considered

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -119,7 +120,8 @@ class CampaignAdmin extends Component {
* @return {string}
*/
getActionRoute(id, view) {
return `/${this.props.sectionConfig.reactRoutePath}/set/${id}/${view}`;
const { reactRoutePath } = this.props.sectionConfig;
return joinUrlPaths(`/${reactRoutePath}`, `/set/${id}/${view}`);
Copy link
Member

Choose a reason for hiding this comment

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

This is possibly better done as
return joinUrlPaths('/', reactRoutePath, `/set/${id}/${view}`);

I'm not sure if reactRouthPath could have a leading slash or not

Same applies for all the other cases of /${reactRoutePath} in this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@GuySartorelli GuySartorelli force-pushed the pulls/2/no-trailing-slashes branch from cb0a868 to 4a9bf33 Compare January 19, 2023 21:39
@GuySartorelli
Copy link
Member Author

webpack-config changes are now included in this PR.

@GuySartorelli GuySartorelli force-pushed the pulls/2/no-trailing-slashes branch from 4a9bf33 to f3b933b Compare January 20, 2023 02:17
@GuySartorelli GuySartorelli marked this pull request as ready for review January 20, 2023 02:17
@GuySartorelli GuySartorelli force-pushed the pulls/2/no-trailing-slashes branch from f3b933b to a2a95ae Compare January 20, 2023 02:18
@GuySartorelli
Copy link
Member Author

Rebased to resolve conflicts

@GuySartorelli GuySartorelli merged commit 8dffaa5 into silverstripe:2 Jan 20, 2023
@GuySartorelli GuySartorelli deleted the pulls/2/no-trailing-slashes branch January 20, 2023 02:25
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.

2 participants