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.
What problem does this address?
See the relevant code here:
gutenberg/packages/e2e-test-utils-playwright/src/request-utils/plugins.ts
Lines 28 to 30 in 667fa36
kebabCaseturns a plugin name like "SQLite Object Cache" intosq-lite-object-cache, whereas the correct plugin slug would besqlite-object-cache. Same for "DynaMo", which is turned intodyna-moinstead ofdynamoWhat is your proposed solution?
Use
toLowerCase()before runningkebabCase(). That's whatsanitize_titledoes 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:
This could be achieved by going through the
pluginsMapand 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.