From 850d61678ac7c6af7f2007f6efd855455ee36e3f Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sun, 2 Jul 2023 23:50:19 +0200 Subject: [PATCH] Add a "." between the subdomain and domain names, only when needed. --- spago.dhall | 1 + src/App/DNSManagerDomainsInterface.purs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spago.dhall b/spago.dhall index e8212be..ba24387 100644 --- a/spago.dhall +++ b/spago.dhall @@ -24,6 +24,7 @@ , "prelude" , "profunctor" , "strings" + , "stringutils" , "transformers" , "tuples" , "uint" diff --git a/src/App/DNSManagerDomainsInterface.purs b/src/App/DNSManagerDomainsInterface.purs index 939ddb5..577f56a 100644 --- a/src/App/DNSManagerDomainsInterface.purs +++ b/src/App/DNSManagerDomainsInterface.purs @@ -15,6 +15,8 @@ import Prelude import Bulma as Bulma +import Data.String.Utils (endsWith) +-- import Data.String.CodeUnits as DSCU import Halogen.HTML.Events as HHE import Control.Monad.Except (runExcept) import Control.Monad.State (class MonadState) @@ -344,7 +346,7 @@ handleAction = case _ of H.liftEffect $ Event.preventDefault ev { wsInfo, newDomainForm } <- H.get - let new_domain = newDomainForm.new_domain <> newDomainForm.selected_domain + let new_domain = build_new_domain newDomainForm.new_domain newDomainForm.selected_domain case wsInfo.connection, new_domain of Nothing, _ -> @@ -461,6 +463,12 @@ handleAction = case _ of , "]" ] +build_new_domain :: String -> String -> String +build_new_domain sub tld + | sub == "" = "." <> tld + | endsWith "." sub = sub <> tld + | otherwise = sub <> "." <> tld + sendArrayBuffer :: WS.WebSocket -> ArrayBuffer -> Effect Unit sendArrayBuffer = WS.sendArrayBuffer