File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ module Routing.Parser (
22 parse
33 ) where
44
5- import Data.Array as A
6- import Data.Map as M
7- import Data.String as S
85import Control.MonadPlus (guard )
6+ import Data.Array as A
97import Data.Either (fromRight )
108import Data.List (fromFoldable , List )
9+ import Data.Map as M
1110import Data.Maybe (Maybe , fromMaybe )
12- import Data.String.Regex (regex , split ) as R
11+ import Data.String as S
12+ import Data.String.Regex (Regex , regex , split ) as R
1313import Data.String.Regex.Flags (noFlags ) as R
1414import Data.Traversable (traverse )
1515import Data.Tuple (Tuple (..))
@@ -36,8 +36,11 @@ parsePart str = fromMaybe (Path str) do
3636 Tuple <$> (A .head keyVal) <*> (keyVal A .!! 1 )
3737
3838
39+ splitRegex :: R.Regex
40+ splitRegex = unsafePartial fromRight $ R .regex " \\ /|(?=\\ ?)" R .noFlags
41+
3942-- | Parse hash string to `Route` with `decoder` function
4043-- | applied to every hash part (usually `decodeURIComponent`)
4144parse :: (String -> String ) -> String -> Route
4245parse decoder hash =
43- map ( decoder >>> parsePart ) $ fromFoldable (R .split (unsafePartial fromRight $ R .regex " \\ /|(?= \\ ?) " R .noFlags) hash)
46+ map ( decoder >>> parsePart ) $ fromFoldable (R .split splitRegex hash)
You can’t perform that action at this time.
0 commit comments