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

Improve kebabCase usage in plugin request utils #52411

Closed
swissspidy opened this issue Jul 7, 2023 · 0 comments · Fixed by #52414
Closed

Improve kebabCase usage in plugin request utils #52411

swissspidy opened this issue Jul 7, 2023 · 0 comments · Fixed by #52414
Assignees
Labels
[Package] E2E Tests /packages/e2e-tests [Tool] E2E Test Utils /packages/e2e-test-utils [Type] Enhancement A suggestion for improvement.

Comments

@swissspidy
Copy link
Member

What problem does this address?

See the relevant code here:

// Ideally, we should be using sanitize_title() in PHP rather than kebabCase(),
// but we don't have the exact port of it in JS.
this.pluginsMap[ kebabCase( plugin.name ) ] = plugin.plugin;

kebabCase turns a plugin name like "SQLite Object Cache" into sq-lite-object-cache, whereas the correct plugin slug would be sqlite-object-cache. Same for "DynaMo", which is turned into dyna-mo instead of dynamo

What is your proposed solution?

Use toLowerCase() before running kebabCase(). That's what sanitize_title does internally as well.

I think that would solve most problems.

In addition to that, we could improve the error message when trying to activate a plugin with the wrong slug.

Example:

The plugin "foo-bar-baz" isn't installed. Did you mean "foobar-baz"?

This could be achieved by going through the pluginsMap and comparing the input with existing slugs, checking for similarity. For example by first removing all hyphens from both strings and then seeing if there is a match.

Bonus: we could actually do this comparison and choose the right plugin automatically, without annoying the developer. But not sure if that's desired.

@swissspidy swissspidy added [Type] Enhancement A suggestion for improvement. [Tool] E2E Test Utils /packages/e2e-test-utils [Package] E2E Tests /packages/e2e-tests labels Jul 7, 2023
@swissspidy swissspidy self-assigned this Jul 7, 2023
@swissspidy swissspidy added the [Status] In Progress Tracking issues with work in progress label Jul 7, 2023
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Tests /packages/e2e-tests [Tool] E2E Test Utils /packages/e2e-test-utils [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants