mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
fix: componentName can contain dot notation
This commit is contained in:
parent
3e485b07da
commit
3a0ab6d441
@ -16,7 +16,7 @@ import {
|
|||||||
IWithDependency,
|
IWithDependency,
|
||||||
} from '../../types';
|
} from '../../types';
|
||||||
|
|
||||||
import { isValidIdentifier } from '../../utils/validate';
|
import { isValidIdentifier, isValidComponentName } from '../../utils/validate';
|
||||||
|
|
||||||
// TODO: main 这个信息到底怎么用,是不是外部包不需要使用?
|
// TODO: main 这个信息到底怎么用,是不是外部包不需要使用?
|
||||||
const DEP_MAIN_BLOCKLIST = ['lib', 'lib/index', 'es', 'es/index', 'main'];
|
const DEP_MAIN_BLOCKLIST = ['lib', 'lib/index', 'es', 'es/index', 'main'];
|
||||||
@ -261,7 +261,7 @@ function buildPackageImport(
|
|||||||
if (!isValidIdentifier(name)) {
|
if (!isValidIdentifier(name)) {
|
||||||
throw new CodeGeneratorError(`Invalid Identifier [${name}]`);
|
throw new CodeGeneratorError(`Invalid Identifier [${name}]`);
|
||||||
}
|
}
|
||||||
if (info.nodeIdentifier && !isValidIdentifier(info.nodeIdentifier)) {
|
if (info.nodeIdentifier && !isValidComponentName(info.nodeIdentifier)) {
|
||||||
throw new CodeGeneratorError(`Invalid Identifier [${info.nodeIdentifier}]`);
|
throw new CodeGeneratorError(`Invalid Identifier [${info.nodeIdentifier}]`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,6 +2,10 @@ export const isValidIdentifier = (name: string) => {
|
|||||||
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(name);
|
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isValidComponentName = (name: string) => {
|
||||||
|
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF.]*$/.test(name);
|
||||||
|
};
|
||||||
|
|
||||||
export const ensureValidClassName = (name: string) => {
|
export const ensureValidClassName = (name: string) => {
|
||||||
if (!isValidIdentifier(name)) {
|
if (!isValidIdentifier(name)) {
|
||||||
return `$${name.replace(/[^_$a-zA-Z0-9]/g, '')}`;
|
return `$${name.replace(/[^_$a-zA-Z0-9]/g, '')}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user