Skip to content
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

Merged
merged 10 commits into from
Aug 17, 2021
Merged

Conversation

tonny008
Copy link
Contributor

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

@strapi-cla
Copy link

strapi-cla commented Jun 18, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@petersg83 petersg83 left a 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?

@tonny008
Copy link
Contributor Author

I don’t think it’s common beginnings here.

Given:
http://example.com/api
http://example.com/admin

common beginnings is http://example.com/a,
Common path is http://example.com

use common beginning the admin path will be dmin

@petersg83
Copy link
Contributor

You're right I didn't see that. Thank you.
Can you please move the function next to commonBeginning in /packages/core/utils/lib/string-formatting.js?
And if you have time to write a few tests in /packages/core/utils/lib/__tests__/string-formatting.test.js, it would be perfect.
Otherwise I can do it too

Copy link
Contributor

@petersg83 petersg83 left a 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?

petersg83
petersg83 previously approved these changes Jun 30, 2021
Copy link
Contributor

@petersg83 petersg83 left a 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
Copy link

codecov bot commented Jun 30, 2021

Codecov Report

Merging #10509 (109b933) into master (1c424ad) will increase coverage by 0.11%.
The diff coverage is 88.88%.

❗ Current head 109b933 differs from pull request most recent head ce51257. Consider uploading reports for the commit ce51257 to get more accurate results
Impacted file tree graph

@@            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     
Flag Coverage Δ
front ∅ <ø> (∅)
unit 58.12% <88.88%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/strapi-utils/lib/config.js 60.46% <50.00%> (ø)
packages/strapi-utils/lib/string-formatting.js 100.00% <100.00%> (+40.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c424ad...ce51257. Read the comment docs.

@alexandrebodin
Copy link
Member

Hi there 👋 Do you think you will be able to finish the changes requested at some point ?

@petersg83 petersg83 added this to the 3.6.7 milestone Aug 11, 2021
@petersg83 petersg83 added source: core:strapi Source is core/strapi package issue: enhancement Issue suggesting an enhancement to an existing feature labels Aug 11, 2021
@alexandrebodin alexandrebodin merged commit 7a80bda into strapi:master Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: core:strapi Source is core/strapi package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants