Handle extension names in npm org scopes (#20209)

* Handle extension names in npm org scopes

Fixes #20142

* Add changeset
This commit is contained in:
Rijk van Zanten
2023-10-26 18:41:30 -04:00
committed by GitHub
parent 46d5a8ddde
commit 9afbc6efaf
2 changed files with 23 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/api': patch
---
Fixed an issue that would prevent npm-organization scoped packages from showing up in the extensions pane in the app

View File

@@ -120,7 +120,24 @@ export class ExtensionsService {
let name = meta.name;
if (name.includes('/')) {
[bundleName, name] = name.split('/') as [string, string];
const parts = name.split('/');
// NPM packages can have an optional organization scope in the format
// `@<org>/<package>`. This is limited to a single `/`.
//
// `foo` -> extension
// `foo/bar` -> bundle
// `@rijk/foo` -> extension
// `@rijk/foo/bar -> bundle
const hasOrg = parts.at(0)!.startsWith('@');
if (hasOrg && parts.length > 2) {
name = parts.pop() as string;
bundleName = parts.join('/');
} else if (hasOrg === false) {
[bundleName, name] = parts as [string, string];
}
}
let schema;