mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 12:54:07 +03:00
cli: Commands.Balance.registerQueryUrl: correctly escape URL using modern-uri package
This commit is contained in:
parent
3cd6e95746
commit
9cdd21bf6d
@ -238,6 +238,7 @@ Currently, empty cells show 0.
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hledger.Cli.Commands.Balance (
|
||||
-- ** balance command
|
||||
@ -283,6 +284,8 @@ import Data.Time (addDays, fromGregorian)
|
||||
import System.Console.CmdArgs.Explicit as C (flagNone, flagReq, flagOpt)
|
||||
import Lucid as L hiding (value_)
|
||||
import Safe (headMay, maximumMay)
|
||||
import qualified Text.URI as Uri
|
||||
import qualified Text.URI.QQ as UriQQ
|
||||
import Text.Tabular.AsciiWide
|
||||
(Header(..), Align(..), Properties(..), Cell(..), Table(..), TableOpts(..),
|
||||
cellWidth, concatTables, renderColumns, renderRowB, renderTableByRowsB, textCell)
|
||||
@ -586,8 +589,14 @@ headerCell text =
|
||||
|
||||
registerQueryUrl :: [Text] -> Text
|
||||
registerQueryUrl query =
|
||||
"register?q=" <>
|
||||
T.intercalate "+" (map quoteIfSpaced $ filter (not . T.null) query)
|
||||
Uri.render $
|
||||
[UriQQ.uri|register|] {
|
||||
Uri.uriQuery =
|
||||
[Uri.QueryParam [UriQQ.queryKey|q|] $
|
||||
fromMaybe (error "register URI query construction failed") $
|
||||
Uri.mkQueryValue $ T.unwords $
|
||||
map quoteIfSpaced $ filter (not . T.null) query]
|
||||
}
|
||||
|
||||
-- cf. Web.Widget.Common
|
||||
removeDates :: [Text] -> [Text]
|
||||
|
@ -172,6 +172,7 @@ library
|
||||
, math-functions >=0.3.3.0
|
||||
, megaparsec >=7.0.0 && <9.7
|
||||
, microlens >=0.4
|
||||
, modern-uri >=0.3
|
||||
, mtl >=2.2.1
|
||||
, process
|
||||
, regex-tdfa
|
||||
|
@ -205,6 +205,7 @@ library:
|
||||
- Diff >=0.2
|
||||
- hashable >=1.2.4
|
||||
- lucid
|
||||
- modern-uri >=0.3
|
||||
|
||||
executables:
|
||||
hledger:
|
||||
|
Loading…
Reference in New Issue
Block a user