Revert "Make subdomain minimum length configurable via env var" (#23871)
Instead, reduce the subdomain minimum length to 1 char <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/23871?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export const DEFAULT_SUBDOMAIN_MIN_LENGTH = 3;
|
||||
@@ -1,4 +1,4 @@
|
||||
// Up to 30 chars: lowercase alphanumeric and hyphens, must start and end
|
||||
// with a letter or number, must not start with "api-". Minimum length is
|
||||
// enforced separately by the caller so it can be configurable.
|
||||
export const SUBDOMAIN_PATTERN = /^(?!api-)[a-z0-9]([a-z0-9-]{0,28}[a-z0-9])?$/;
|
||||
// 1-30 chars: lowercase alphanumeric and hyphens, must start and end
|
||||
// with a letter or number, must not start with "api-"
|
||||
export const SUBDOMAIN_PATTERN =
|
||||
/^(?!api-)[a-z0-9](?:[a-z0-9-]{0,28}[a-z0-9])?$/;
|
||||
|
||||
@@ -61,7 +61,6 @@ export { RATING_VALUES } from './RatingValues';
|
||||
export { RELATION_NESTED_QUERY_KEYWORDS } from './RelationNestedQueriesKeyword';
|
||||
export { RESERVED_SUBDOMAINS } from './ReservedSubdomains';
|
||||
export { STANDARD_OBJECT_RECORDS_UNDER_OBJECT_RECORDS_PERMISSIONS } from './StandardObjectRecordsUnderObjectRecordsPermissions';
|
||||
export { DEFAULT_SUBDOMAIN_MIN_LENGTH } from './SubdomainMinLength';
|
||||
export { SUBDOMAIN_PATTERN } from './SubdomainPattern';
|
||||
export { SystemPermissionFlag } from './SystemPermissionFlag';
|
||||
export { TWENTY_COMPANIES_BASE_URL } from './TwentyCompaniesBaseUrl';
|
||||
|
||||
+3
-2
@@ -41,8 +41,9 @@ describe('getSubdomainSlugFromDisplayName', () => {
|
||||
expect(getSubdomainSlugFromDisplayName('日本語')).toBe('ri-ben-yu');
|
||||
});
|
||||
|
||||
it('should return undefined when the result is shorter than the minimum length', () => {
|
||||
expect(getSubdomainSlugFromDisplayName('AB')).toBeUndefined();
|
||||
it('should accept results as short as a single character', () => {
|
||||
expect(getSubdomainSlugFromDisplayName('AB')).toBe('ab');
|
||||
expect(getSubdomainSlugFromDisplayName('A')).toBe('a');
|
||||
});
|
||||
|
||||
it('should clamp long names to the maximum length without a trailing hyphen', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { slugify } from 'transliteration';
|
||||
|
||||
import { isDefined } from '@/utils/validation/isDefined';
|
||||
|
||||
const SUBDOMAIN_MIN_LENGTH = 3;
|
||||
const SUBDOMAIN_MIN_LENGTH = 1;
|
||||
const SUBDOMAIN_MAX_LENGTH = 30;
|
||||
|
||||
export const getSubdomainSlugFromDisplayName = (
|
||||
|
||||
+2
-4
@@ -16,12 +16,10 @@ describe('isValidTwentySubdomain', () => {
|
||||
expect(isValidTwentySubdomain('a-b-c-d-e')).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept short subdomains regardless of minimum length', () => {
|
||||
// Minimum length is enforced by the caller, not by the pattern
|
||||
it('should accept minimum length subdomains (1 character)', () => {
|
||||
expect(isValidTwentySubdomain('a')).toBe(true);
|
||||
expect(isValidTwentySubdomain('1')).toBe(true);
|
||||
expect(isValidTwentySubdomain('ab')).toBe(true);
|
||||
expect(isValidTwentySubdomain('abc')).toBe(true);
|
||||
expect(isValidTwentySubdomain('a1b')).toBe(true);
|
||||
expect(isValidTwentySubdomain('a-b')).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user