Provide utils from purescript-globals instead of FFI (#145)
This commit is contained in:
parent
ae56c9f0a1
commit
88e1dcde9e
@ -46,6 +46,7 @@
|
||||
"purescript-strings": "^4.0.0",
|
||||
"purescript-tuples": "^5.1.0",
|
||||
"purescript-type-equality": "^3.0.0",
|
||||
"purescript-unsafe-coerce": "^4.0.0"
|
||||
"purescript-unsafe-coerce": "^4.0.0",
|
||||
"purescript-globals": "^4.1.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "purescript-httpure",
|
||||
"set": "psc-0.12.2",
|
||||
"set": "psc-0.13.2-20190815",
|
||||
"source": "https://github.com/purescript/package-sets.git",
|
||||
"depends": [
|
||||
"aff",
|
||||
@ -13,6 +13,7 @@
|
||||
"exceptions",
|
||||
"foldable-traversable",
|
||||
"foreign",
|
||||
"globals",
|
||||
"lists",
|
||||
"maybe",
|
||||
"newtype",
|
||||
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
exports.encodeURIComponent = encodeURIComponent
|
||||
|
||||
exports.decodeURIComponentImpl = function(s) {
|
||||
try {
|
||||
return decodeURIComponent(s);
|
||||
} catch(error) {
|
||||
return null;
|
||||
}
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
module HTTPure.Utils
|
||||
( encodeURIComponent
|
||||
, decodeURIComponent
|
||||
( module Global
|
||||
, encodeURIComponent
|
||||
, replacePlus
|
||||
, urlDecode
|
||||
) where
|
||||
@ -8,16 +8,13 @@ module HTTPure.Utils
|
||||
import Prelude
|
||||
|
||||
import Data.Maybe as Maybe
|
||||
import Data.Nullable as Nullable
|
||||
import Data.String as String
|
||||
import Global (decodeURIComponent) as Global
|
||||
import Global.Unsafe (unsafeEncodeURIComponent)
|
||||
|
||||
|
||||
foreign import encodeURIComponent :: String -> String
|
||||
|
||||
foreign import decodeURIComponentImpl :: String -> Nullable.Nullable String
|
||||
|
||||
decodeURIComponent :: String -> Maybe.Maybe String
|
||||
decodeURIComponent = Nullable.toMaybe <<< decodeURIComponentImpl
|
||||
encodeURIComponent :: String -> String
|
||||
encodeURIComponent = unsafeEncodeURIComponent
|
||||
|
||||
|
||||
replacePlus :: String -> String
|
||||
@ -27,4 +24,4 @@ replacePlus =
|
||||
|
||||
urlDecode :: String -> String
|
||||
urlDecode s =
|
||||
Maybe.fromMaybe s $ decodeURIComponent s
|
||||
Maybe.fromMaybe s $ Global.decodeURIComponent s
|
||||
|
Loading…
Reference in New Issue
Block a user