hexo/node_modules/ali-oss/lib/common/utils/checkBucketName.ts

7 lines
307 B
TypeScript
Raw Normal View History

2023-09-25 15:58:56 +08:00
export const checkBucketName = (name: string, createBucket = false): void => {
const bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/;
if (!bucketRegex.test(name)) {
throw new Error('The bucket must be conform to the specifications');
}
};