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"
, "profunctor"
, "strings"
, "stringutils"
, "transformers"
, "tuples"
, "uint"

View File

@ -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