Sanitize suggested FQDN
This commit is contained in:
parent
392653aace
commit
820de7e470
1 changed files with 11 additions and 1 deletions
|
|
@ -23,9 +23,19 @@ const initializeFqdnGeneration = (prefix) => {
|
|||
if (!fqdnField) return
|
||||
|
||||
if (nameField && fqdnField) {
|
||||
const sanitizeForFqdn = (name) => {
|
||||
return name
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9-]/g, '-') // Replace invalid chars with hyphens
|
||||
.replace(/-+/g, '-') // Collapse multiple hyphens
|
||||
.replace(/^-|-$/g, ''); // Trim hyphens from start/end
|
||||
}
|
||||
|
||||
const generateFqdn = (instanceName) => {
|
||||
if (!instanceName) return '';
|
||||
return `${instanceName}-${fqdnConfig.namespace}.${fqdnConfig.wildcardDns}`;
|
||||
const sanitized = sanitizeForFqdn(instanceName);
|
||||
if (!sanitized) return ''
|
||||
return `${sanitized}-${fqdnConfig.namespace}.${fqdnConfig.wildcardDns}`;
|
||||
}
|
||||
|
||||
nameField.addEventListener('input', function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue