Skip to content

Commit b56ae21

Browse files
committed
Fix RegExp constructor
1 parent 29c1c4f commit b56ae21

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Data/JSString/RegExp.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ data Match = Match { matched :: !JSString -- ^ the matched string
3838
}
3939

4040
create :: REFlags -> JSString -> RegExp
41-
create flags pat = js_createRE (multiline flags)
42-
(ignoreCase flags)
43-
pat
41+
create flags pat = js_createRE pat $ pack $
42+
if multiline flags then "m" else ""
43+
++
44+
if ignoreCase flags then "i" else ""
45+
{-# INLINE create #-}
4446

4547
pattern :: RegExp -> JSString
4648
pattern re = js_pattern re
@@ -51,8 +53,6 @@ isMultiline re = js_isMultiline re
5153
isIgnoreCase :: RegExp -> Bool
5254
isIgnoreCase re = js_isIgnoreCase re
5355

54-
{-# INLINE create #-}
55-
5656
test :: JSString -> RegExp -> Bool
5757
test x re = js_test x re
5858
{-# INLINE test #-}
@@ -93,7 +93,7 @@ splitN (I# k) x r = unsafeCoerce (js_split k x r)
9393
-- ----------------------------------------------------------------------------
9494

9595
foreign import javascript unsafe
96-
"new RegExp($1,$2,$3)" js_createRE :: Bool -> Bool -> JSString -> RegExp
96+
"new RegExp($1,$2)" js_createRE :: JSString -> JSString -> RegExp
9797
foreign import javascript unsafe
9898
"$2.test($1)" js_test :: JSString -> RegExp -> Bool
9999
foreign import javascript unsafe

0 commit comments

Comments
 (0)