Skip to content

Commit c7b8773

Browse files
author
Sjoerd Visscher
committed
Url encode parenthesis
1 parent 33e197f commit c7b8773

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/View/App.purs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Data.Lens.Record (prop)
1010
import Data.List (List(Nil))
1111
import Data.Maybe (Maybe(..), maybe)
1212
import Data.Set as Set
13-
import Data.String.Pattern (Pattern(..))
14-
import Data.String.Common (split)
13+
import Data.String (replaceAll, split, Pattern(..), Replacement(..))
1514
import Data.Symbol (SProxy(..))
1615
import Effect.Class (class MonadEffect, liftEffect)
1716
import Global (encodeURIComponent)
@@ -163,10 +162,14 @@ updateWindowLocation { pixels, context } =
163162
liftEffect do
164163
w <- window
165164
l <- location w
166-
for_ (encodeURIComponent pixels) \p ->
167-
for_ (encodeURIComponent context) \c ->
165+
for_ (escape pixels) \p ->
166+
for_ (escape context) \c ->
168167
setHash ("pixels=" <> p <> "&context=" <> c) l
169168

169+
escape :: String -> Maybe String
170+
escape s = encodeURIComponent s
171+
<#> replaceAll (Pattern "(") (Replacement "%28")
172+
<#> replaceAll (Pattern ")") (Replacement "%29")
170173

171174
parsePixels :: String -> Array (Array String)
172175
parsePixels = map (split (Pattern "")) <<< split (Pattern "\n")

0 commit comments

Comments
 (0)