mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Handle extension names in npm org scopes (#20209)
* Handle extension names in npm org scopes Fixes #20142 * Add changeset
This commit is contained in:
5
.changeset/thick-wolves-train.md
Normal file
5
.changeset/thick-wolves-train.md
Normal 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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user