diff --git a/.changeset/thick-wolves-train.md b/.changeset/thick-wolves-train.md new file mode 100644 index 0000000000..9a190bdd8b --- /dev/null +++ b/.changeset/thick-wolves-train.md @@ -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 diff --git a/api/src/services/extensions.ts b/api/src/services/extensions.ts index be822d306a..14ddc321ee 100644 --- a/api/src/services/extensions.ts +++ b/api/src/services/extensions.ts @@ -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 + // `@/`. 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;