Add a "." between the subdomain and domain names, only when needed.

This commit is contained in:
Philippe Pittoli 2023-07-02 23:50:19 +02:00
parent 02f312b447
commit 850d61678a
2 changed files with 10 additions and 1 deletions

View File

@ -24,6 +24,7 @@
, "prelude" , "prelude"
, "profunctor" , "profunctor"
, "strings" , "strings"
, "stringutils"
, "transformers" , "transformers"
, "tuples" , "tuples"
, "uint" , "uint"

View File

@ -15,6 +15,8 @@ import Prelude
import Bulma as Bulma import Bulma as Bulma
import Data.String.Utils (endsWith)
-- import Data.String.CodeUnits as DSCU
import Halogen.HTML.Events as HHE import Halogen.HTML.Events as HHE
import Control.Monad.Except (runExcept) import Control.Monad.Except (runExcept)
import Control.Monad.State (class MonadState) import Control.Monad.State (class MonadState)
@ -344,7 +346,7 @@ handleAction = case _ of
H.liftEffect $ Event.preventDefault ev H.liftEffect $ Event.preventDefault ev
{ wsInfo, newDomainForm } <- H.get { 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 case wsInfo.connection, new_domain of
Nothing, _ -> 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.WebSocket -> ArrayBuffer -> Effect Unit
sendArrayBuffer = WS.sendArrayBuffer sendArrayBuffer = WS.sendArrayBuffer