From 42f55418fcdf1e9403ce666c5e5338fb5a40a182 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Sat, 18 Nov 2023 17:42:22 -0600 Subject: [PATCH] fix: use node url --- spago.yaml | 1 + src/HTTP.purs | 6 +++--- src/HTTP/Request.purs | 2 +- src/HTTP/URL.purs | 12 ------------ 4 files changed, 5 insertions(+), 16 deletions(-) delete mode 100644 src/HTTP/URL.purs diff --git a/spago.yaml b/spago.yaml index 49bca1e..01eaa2a 100644 --- a/spago.yaml +++ b/spago.yaml @@ -10,6 +10,7 @@ package: - maybe - newtype - node-buffer + - node-url - prelude - simple-json - strings diff --git a/src/HTTP.purs b/src/HTTP.purs index e925f2b..91028ef 100644 --- a/src/HTTP.purs +++ b/src/HTTP.purs @@ -4,7 +4,6 @@ import Prelude import Control.Promise (Promise) import Control.Promise as Promise -import Data.Newtype (unwrap) import Data.Nullable (Nullable) import Data.Nullable as Nullable import Effect (Effect) @@ -15,8 +14,9 @@ import HTTP.Header (headers) as X import HTTP.Request (class Request, Method(..)) as X import HTTP.Request as Req import HTTP.Response (Response) +import Node.URL (URL) -foreign import fetchImpl :: String -> String -> Object String -> Nullable Req.RawRequestBody -> Effect (Promise Response) +foreign import fetchImpl :: URL -> String -> Object String -> Nullable Req.RawRequestBody -> Effect (Promise Response) fetch :: forall m a. MonadAff m => Req.Request a => a -> m Response fetch req = do @@ -34,4 +34,4 @@ fetch req = do Req.DELETE -> "DELETE" headers' = Object.fromFoldableWithIndex headers - liftAff $ Promise.toAffE $ fetchImpl (unwrap url) methodStr headers' $ Nullable.toNullable body + liftAff $ Promise.toAffE $ fetchImpl url methodStr headers' $ Nullable.toNullable body diff --git a/src/HTTP/Request.purs b/src/HTTP/Request.purs index 974ed0f..63c7b2b 100644 --- a/src/HTTP/Request.purs +++ b/src/HTTP/Request.purs @@ -34,7 +34,7 @@ import HTTP.Header (ContentType(..), Headers(..)) import HTTP.Header as Header import HTTP.MIME (MIME) import HTTP.MIME as MIME -import HTTP.URL (URL) +import Node.URL (URL) import Node.Buffer (Buffer) import Node.Buffer as Buffer import Node.Encoding (Encoding(..)) diff --git a/src/HTTP/URL.purs b/src/HTTP/URL.purs deleted file mode 100644 index b8809a0..0000000 --- a/src/HTTP/URL.purs +++ /dev/null @@ -1,12 +0,0 @@ -module HTTP.URL where - -import Prelude - -import Data.Newtype (class Newtype) - -newtype URL = URL String - -derive instance Newtype URL _ -derive newtype instance Show URL -derive newtype instance Eq URL -derive newtype instance Ord URL