diff --git a/lib/registration.rb b/lib/registration.rb index b380e532f8529245a91b62c18274f876f552d929..358ac2d9800465ba671b9b7d2d26c681e2f40657 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -641,7 +641,7 @@ class Registration end def next_step(iq) - subdomain = iq.form.field("subdomain")&.value + subdomain = empty_nil(iq.form.field("subdomain")&.value) domain = "#{subdomain}.snikket.chat" if iq.form.field(ACTION_VAR)&.value == "custom_domain" CustomDomain.new(@customer, @tel, old: @old).write @@ -676,6 +676,10 @@ class Registration end end + def empty_nil(s) + s.nil? || s.empty? ? nil : s + end + class NeedsDNS < Snikket def initialize(customer, instance, tel, records, db: DB) @customer = customer @@ -784,7 +788,7 @@ class Registration if iq.prev? Snikket.new(@customer, @tel, db: @db, old: @old).write else - launch(iq.form.field("domain")&.value) + launch(empty_nil(iq.form.field("domain")&.value) || @old&.domain) end end end