Skip to content

Commit f24affa

Browse files
committed
Move all logic to PS
1 parent 0d6d3d4 commit f24affa

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

src/Data/URI/Common.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Data/URI/Common.purs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module Data.URI.Common where
33
import Prelude
44

55
import Control.Alt ((<|>))
6-
import Data.Array (fromFoldable)
6+
import Control.MonadZero (guard)
7+
import Data.Array (fromFoldable, head)
78
import Data.Either (Either(..), fromRight)
89
import Data.List (List)
910
import Data.Maybe (Maybe(..))
@@ -78,14 +79,12 @@ anyMatch rx = Parser \{ str: str, pos: i } → case match1From rx i str of
7879
NothingLeft { error: (ParseError $ "Expected " <> show rx), pos: i }
7980

8081
match1From RX.Regex Int String Maybe String
81-
match1From rx' n str =
82+
match1From rx' n str' =
8283
case RX.regex (RX.source rx') (RXF.global <> RX.flags rx') of
8384
Left _ -> Nothing
84-
Right rx -> match1FromImpl Just Nothing rx (S.drop n str)
85-
86-
foreign import match1FromImpl
87-
( a. a Maybe a)
88-
( a. Maybe a)
89-
RX.Regex
90-
String
91-
(Maybe String)
85+
Right rx -> do
86+
let str = S.drop n str'
87+
i <- RX.search rx str
88+
guard $ i == 0
89+
matches <- RX.match rx str
90+
join $ head matches

0 commit comments

Comments
 (0)