-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
change common beginning to common path #10509
Conversation
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.
Hi :)
Thanks for your contribution. The code can be improved indeed.
I read your code, here is a proposition of something even shorter and generic:
const getCommonBeginning = (...strings) => takeWhile(
strings[0],
(char, index) => strings.every(string => string[index] === char)
).join('');
Can you directly change the function getCommonBeginning
in /packages/core/utils/lib/string-formatting.js
?
Also can you add some tests for this function in /packages/core/utils/lib/__tests__/string-formatting.test.js
?
I don’t think it’s common beginnings here. Given: common beginnings is http://example.com/a, use common beginning the admin path will be dmin |
You're right I didn't see that. Thank you. |
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.
Thank you, you did everything :D
I proposed a couple more tests. What do you think?
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.
It looks good to me! Thank you for this contribution!
Codecov Report
@@ Coverage Diff @@
## master #10509 +/- ##
==========================================
+ Coverage 58.01% 58.12% +0.11%
==========================================
Files 185 185
Lines 6431 6429 -2
Branches 1398 1395 -3
==========================================
+ Hits 3731 3737 +6
+ Misses 2236 2230 -6
+ Partials 464 462 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Hi there 👋 Do you think you will be able to finish the changes requested at some point ? |
What does it do?
Change common beginning to common path
Why is it needed?
server.js
url: http://example.com/api
admin.url http://example.com/admin
use common beginning the admin path will be
dmin