From 209a1073b1d36f85e95b0d9b76435e46cc6f8f14 Mon Sep 17 00:00:00 2001 From: Dale Blackburn Date: Tue, 2 Oct 2018 20:38:54 +0100 Subject: [PATCH 1/3] updated gatsby-plugin-remove-trailing-slashes docs to include link resolution considerations --- .../gatsby-plugin-remove-trailing-slashes/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/gatsby-plugin-remove-trailing-slashes/README.md b/packages/gatsby-plugin-remove-trailing-slashes/README.md index a94e038f6ec47..898fa5b86bded 100644 --- a/packages/gatsby-plugin-remove-trailing-slashes/README.md +++ b/packages/gatsby-plugin-remove-trailing-slashes/README.md @@ -3,6 +3,19 @@ This plugin removes trailing slashes from your project's paths. For example, `yoursite.com/about/` becomes `yoursite.com/about`. +## Important considerations +This plugin is intended to remove trailing slashes from paths generated by Gatsby itself. + +This however does not prevent the resolution of pages that have trailing slashes, due to the way browsers are built to interpret URLs as paths. + +This means that a user will need to take the extra step of ensuring that all router links direct towards paths that do not end in a slash. + +For example, `` will render the view related to `/about` but will display as `/about/` in the browsers address bar. + +This is an important factor when relying on path driven logic, such as in the use case of the `Link` components `activeClassName` and `activeStyle` props. + +For example, if the current route is `/about`, the component `` wouldn't match because of the slash. + ## Usage Install: From 8ed48165b7e1ab5520e4c6bacd6c6567b8071dcd Mon Sep 17 00:00:00 2001 From: Dale Blackburn Date: Tue, 2 Oct 2018 21:03:42 +0100 Subject: [PATCH 2/3] updated documentation to mention Netlify Pretty URLs feature --- packages/gatsby-plugin-remove-trailing-slashes/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/gatsby-plugin-remove-trailing-slashes/README.md b/packages/gatsby-plugin-remove-trailing-slashes/README.md index 898fa5b86bded..9825c41d3072b 100644 --- a/packages/gatsby-plugin-remove-trailing-slashes/README.md +++ b/packages/gatsby-plugin-remove-trailing-slashes/README.md @@ -16,6 +16,15 @@ This is an important factor when relying on path driven logic, such as in the us For example, if the current route is `/about`, the component `` wouldn't match because of the slash. +#### Netlify Trailing Slashes +[Netlify](https://www.netlify.com) users should also take into account that that the services will match paths to redirect rules regardless of whether or not they contain a trailing slash, potentially causing infinite redirect loops and unexpected behaviours. + +This can be negated through the use of their Pretty URL feature, which rewrites URLs to pretty URLs. + +Please see the Netlify docs for more information: +[https://www.netlify.com/docs/redirects/#trailing-slash](https://www.netlify.com/docs/redirects/#trailing-slash) + + ## Usage Install: From 5192eb6b1e14f6bf37a1365984154d92cee80cee Mon Sep 17 00:00:00 2001 From: Dale Blackburn Date: Tue, 2 Oct 2018 21:22:50 +0100 Subject: [PATCH 3/3] Update README.md --- packages/gatsby-plugin-remove-trailing-slashes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-plugin-remove-trailing-slashes/README.md b/packages/gatsby-plugin-remove-trailing-slashes/README.md index 9825c41d3072b..569d30f7f137f 100644 --- a/packages/gatsby-plugin-remove-trailing-slashes/README.md +++ b/packages/gatsby-plugin-remove-trailing-slashes/README.md @@ -17,7 +17,7 @@ This is an important factor when relying on path driven logic, such as in the us For example, if the current route is `/about`, the component `` wouldn't match because of the slash. #### Netlify Trailing Slashes -[Netlify](https://www.netlify.com) users should also take into account that that the services will match paths to redirect rules regardless of whether or not they contain a trailing slash, potentially causing infinite redirect loops and unexpected behaviours. +[Netlify](https://www.netlify.com) users should also take into account that that the service will match paths to redirect rules regardless of whether or not they contain a trailing slash, potentially causing infinite redirect loops and unexpected behaviours. This can be negated through the use of their Pretty URL feature, which rewrites URLs to pretty URLs.