implemented Helpers.editHost

This commit is contained in:
2021-09-22 14:50:30 -04:00
parent 34ee4a57bc
commit b7737766f6
2 changed files with 29 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Helpers (
textToUrl,
urlToText,
editHost
) where
import qualified Data.List as L
@@ -62,6 +63,17 @@ urlToText url = T.pack $
Just str -> "#" ++ str
Nothing -> ""
-- | Edit the 'host' value of a 'Url'
editHost
:: (String -> Maybe String)
-- ^ the transformation function
-> Url
-- ^ the Url being modified
-> Maybe Url
editHost f url = do
host' <- f $ host url
Just url { host = host' }
subToUrl :: T.Text -> Maybe Url
subToUrl text = case T.splitOn "://" text of
[protT, raw] -> do