Skip to content

Commit 553ad82

Browse files
committed
Merge branch 'develop'
2 parents d702eeb + bf37fd6 commit 553ad82

File tree

1 file changed

+2
-95
lines changed

1 file changed

+2
-95
lines changed

assets/js/hubmanaged.js

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ class HubManaged {
2828
email: this._submitData.email
2929
}
3030
}).done(response => {
31-
// Auto-populate subdomain only if it's a company email
32-
if (response.isCompanyEmail) {
33-
this._submitData.subdomain = emailToSubdomain(this._submitData.email);
31+
if (response.isCompanyEmail && response.domainWithoutSuffix) {
32+
this._submitData.subdomain = response.domainWithoutSuffix;
3433
} else {
35-
// Clear subdomain for non-company emails (freemail, etc.)
3634
this._submitData.subdomain = '';
3735
}
3836
this.onValidationSucceeded();
@@ -135,97 +133,6 @@ class HubManaged {
135133

136134
}
137135

138-
function teamToSubdomain(team) {
139-
// Convert to lowercase
140-
let subdomain = team.toLowerCase();
141-
// Replace German specific characters
142-
subdomain = subdomain.replace(/ß/g, "ss").replace(/ä/g, "ae").replace(/ö/g, "oe").replace(/ü/g, "ue");
143-
// Normalize to decompose accented characters and remove diacritics
144-
subdomain = subdomain.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
145-
// Replace any whitespace (including spaces, tabs, etc.) with a hyphen
146-
subdomain = subdomain.replace(/\s+/g, "-");
147-
// Remove any characters that are not letters, numbers, or hyphens
148-
subdomain = subdomain.replace(/[^a-z0-9-]/g, "");
149-
// Replace multiple hyphens with a single hyphen
150-
subdomain = subdomain.replace(/-+/g, "-");
151-
// Remove any leading or trailing hyphens
152-
subdomain = subdomain.replace(/^-+/, "").replace(/-+$/, "");
153-
// Cap the subdomain at 63 characters
154-
if (subdomain.length > 63) {
155-
subdomain = subdomain.slice(0, 63);
156-
// Remove any trailing hyphen after truncation
157-
subdomain = subdomain.replace(/-+$/, "");
158-
}
159-
return subdomain;
160-
}
161-
162-
function emailToSubdomain(email) {
163-
if (!email || !email.includes('@')) {
164-
return '';
165-
}
166-
167-
// Extract domain from email
168-
const domain = email.split('@')[1].toLowerCase();
169-
170-
// Extract subdomain from email domain
171-
const domainParts = domain.split('.');
172-
173-
// For domains with multiple levels, try to find the most meaningful part
174-
let subdomain = '';
175-
176-
if (domainParts.length >= 2) {
177-
// Common TLDs and country codes to ignore
178-
const tlds = ['com', 'org', 'net', 'edu', 'gov', 'mil', 'co', 'io', 'me', 'info', 'biz'];
179-
const countryCodes = ['de', 'uk', 'fr', 'es', 'it', 'nl', 'at', 'ch', 'us', 'ca', 'au', 'jp', 'cn', 'in', 'br'];
180-
181-
// For academic domains (containing .edu, .ac, .edu.*, .ac.*)
182-
if (domain.includes('.edu') || domain.includes('.ac.')) {
183-
// Try to find the institution name (usually right before .edu/.ac)
184-
for (let i = domainParts.length - 3; i >= 0; i--) {
185-
if (!tlds.includes(domainParts[i]) && !countryCodes.includes(domainParts[i])) {
186-
subdomain = domainParts[i];
187-
break;
188-
}
189-
}
190-
}
191-
192-
// If no academic pattern or no match found, use heuristics
193-
if (!subdomain) {
194-
// Skip the last part (TLD) and country code if present
195-
let skipParts = 1;
196-
if (domainParts.length > 2 && countryCodes.includes(domainParts[domainParts.length - 1])) {
197-
skipParts = 2;
198-
}
199-
200-
// Look for the most meaningful part (skip common subdomains)
201-
const commonSubdomains = ['www', 'mail', 'email', 'smtp', 'pop', 'imap', 'webmail', 'smail'];
202-
for (let i = domainParts.length - skipParts - 1; i >= 0; i--) {
203-
if (!commonSubdomains.includes(domainParts[i])) {
204-
subdomain = domainParts[i];
205-
break;
206-
}
207-
}
208-
209-
// If all parts are common subdomains, just use the first part
210-
if (!subdomain && domainParts.length > skipParts) {
211-
subdomain = domainParts[0];
212-
}
213-
}
214-
215-
// Clean up the subdomain to match the allowed pattern
216-
subdomain = subdomain.replace(/[^a-z0-9-]/g, '-');
217-
subdomain = subdomain.replace(/-+/g, '-');
218-
subdomain = subdomain.replace(/^-+|-+$/g, '');
219-
220-
// Ensure it's not empty and within length limits
221-
if (subdomain && subdomain.length <= 63) {
222-
return subdomain;
223-
}
224-
}
225-
226-
return '';
227-
}
228-
229136
function subdomainToURL(subdomain) {
230137
return `https://${subdomain}.cryptomator.cloud`;
231138
}

0 commit comments

Comments
 (0)