fix(jwt): issue with removing leading slash from keys in user object #228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔧 fix:
Improved the JWT namespace handling within the "fastify-user" plugin to effectively trim any leading slashes from the key. This update addresses cases where the namespace was defined without a trailing slash, which previously resulted in keys beginning with an unintended leading slash. Now, the keys are normalized by removing these leading slashes.
💡refactor:
The logic for processing the JWT namespace has been refined to automatically remove leading slashes from keys whenever the namespace does not end with a slash. This ensures that keys are consistently formatted without any leading slashes, enhancing system reliability and preventing misrouting or path errors in applications.
🔎 Use-case:
Before this update, defining a JWT namespace without a trailing slash led to keys with a leading slash, causing potential misconfigurations in route handling or session management. With the current enhancement, the JWT namespace is sanitized by automatically trimming leading slashes, ensuring that the keys are correctly formatted for seamless integration and operation within the system. This change boosts the robustness of namespace handling, eliminating common errors related to slash misplacement.