-
-
Notifications
You must be signed in to change notification settings - Fork 764
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
Default config ignores any pages that have a path token that starts with static
#455
Comments
The most we could do here is add a trailing slash to these substrings, eg The reason |
I don't mean to be rude, but this is fairly obviously a bug. First, because what the code intends to do (ignore static files) and what it actually does (ignore static files AND all pages that have a path segment starting with Secondly, because I spent an hour this morning "debugging" why our app was blowing up whenever someone wrote a post with a title that started with the word "static". It was only the intuition to search this codebase for use of the If the contract of this library is "you can have i18n but you can no longer have any pages with path segments that start with the word I think I've already expressed the issue pretty clearly, expressed the "expected behaviour" (i.e. how the library can improve) pretty clearly, pointed directly to the lines of code causing the issue, and offered to do the work myself to make a pull request to fix it. So I'm not sure how i could have been a better open-source citizen in this case, and I'm confused as to why you feel the need to tell me that the bug I'm reporting is not a "bug", and that you need some "clear suggestions" about how to improve other than the clear suggestions already in the bug report? But if it helps:
And to reiterate, I'm more than happy to put together a pull request that makes these fixes. I don't know the internals of this library, so I thought I would call your attention to the issue before attempting to make a fix in case there might be any unintended consequences I would not have foreseen. |
PRs welcome. |
Describe the bug
Default values for the
ignoreRoutes
option include/static
without a trailing slash: https://github.com/isaachinman/next-i18next/blob/09be96fad33d37f38997cf89103a4b7d690518a8/src/config/default-config.ts#L29Presumably this is intended to prevent i18n from being loaded for static files - however as the code checks these values with
startsWith
:https://github.com/isaachinman/next-i18next/blob/09be96fad33d37f38997cf89103a4b7d690518a8/src/middlewares/next-i18next-middleware.ts#L21
it also prevents loading of i18n for any routes that start with
/static
. Such as, for example:my.blog.com/static-typing-is-cool
.For us it also seems to happen when any path token at all starts with
static
: somy.blog.com/posts/static-typing-is-cool
would also be ignored. Haven't gotten to the bottom of this.Occurs in next-i18next version
We're using 0.44.0 but as you can see from the links above, the code that causes this is still in master.
Steps to reproduce
Using i18next without overriding the default
ignoreRoutes
option, and creating a page, wrapped in the i18n middleware, whose url starts with/static
, will reproduce this bug.Expected behaviour
Only paths that start with
/static/
or/_next/
should be ignored by default. It may be that custom asset prefixes also need to be taken into account to make this work, too..OS (please complete the following information)
N/A
Additional context
Happy to submit a PR that changes the default config values but don't know enough about the internals of this library to know if that's likely to have any unintended consequences.
The text was updated successfully, but these errors were encountered: