-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
fix(v2): normalizeUrl edge cases #3427
Conversation
Deploy preview for docusaurus-2 ready! Built without sensitive environment variables with commit 05d305d |
Thanks @ayshiff . That seems to solve the edge cases. However, you should not revert the changes in the other PR, I'd like to keep them, as I don't think it's a good idea to enable users to provide routeBasePath = '' and it also contains other useful refactors. It would be hard for me to review this 🤪 , but I guess if we have tests and they all pass it should be good. What about adding more fancy edge case tests? I'm thinking of things like:
You see what I mean? |
@slorber I understand ! I'll keep the changes in the other PR. |
b3acec6
to
05d305d
Compare
I spotted and fixed two new edge cases:
For the starting slash the problem was that for every element which has an index greater than 1, we removed the starting slashes. So if we have something like We now have a new variable The same problem was present for the ending slash, and the new variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit.
Hi
Will be back from holiday on Monday 28 and catch up with PRs/issues soon 😉
Le mer. 16 sept. 2020 à 08:50, Alexey Pyltsyn <[email protected]> a
écrit :
… ***@***.**** approved this pull request.
Seems legit.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3427 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFW6PUFQ4WRGKVUQAJ6GFDSGBU3TANCNFSM4RCVNSMQ>
.
|
Thanks for your work @ayshiff , seems to be more reliable now ;) |
Motivation
This PR fixes edge cases for the
normalizeUrl
util function like the ones introduced in the unit tests.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
This PR fixes #3374 and undo #3377.
New unit tests added:
The thing was that for each part of our
rawUrls
(except for the last one) we removed the/
in:I added a condition to check if the current element is a slash and if so we can continue the process.
Here is the new logic inside our for loop:
Another workaround would be to add a condition to the returned string like:
return str === '' ? '/' : str
as I think this change target only an edge case.NOTE: I am note sure about this solution ! It would be great if someone could give me their opinion on this 👍
Related PRs
This PR undo the #3377 changes.