diff --git a/elm-package.json b/elm-package.json index ce6a049..462f681 100644 --- a/elm-package.json +++ b/elm-package.json @@ -12,7 +12,6 @@ "dependencies": { "elm-community/maybe-extra": "4.0.0 <= v < 5.0.0", "elm-lang/core": "5.1.1 <= v < 6.0.0", - "elm-lang/html": "2.0.0 <= v < 3.0.0", "elm-lang/http": "1.0.0 <= v < 2.0.0" }, "elm-version": "0.18.0 <= v < 0.19.0" diff --git a/src/Paginated.elm b/src/Paginated.elm index 458069b..6297db5 100644 --- a/src/Paginated.elm +++ b/src/Paginated.elm @@ -37,7 +37,6 @@ import Char import Dict exposing (Dict) import Http import Json.Decode exposing (Decoder) -import Maybe.Extra import Paginated.Util import Task exposing (Task) import Time @@ -130,7 +129,7 @@ send : -> Request a -> Cmd msg send resultToMessage request = - toTask request + toTask request |> Task.attempt resultToMessage @@ -214,18 +213,13 @@ fromResponse options response = (Json.Decode.list options.decoder) response.body - normalize : Dict String String -> Dict String String - normalize = - Dict.toList - >> Dict.fromList - nextPage : Maybe String nextPage = header "Link" response.headers |> Maybe.map Paginated.Util.links |> Maybe.andThen (Dict.get "next") in - case Debug.log "nextPage" nextPage of + case nextPage of Nothing -> Result.map Complete items diff --git a/src/Paginated/Util.elm b/src/Paginated/Util.elm index e576681..73e3396 100644 --- a/src/Paginated/Util.elm +++ b/src/Paginated/Util.elm @@ -25,11 +25,13 @@ links s = _ -> Nothing in - Regex.find - Regex.All - (Regex.regex "<(.*?)>; rel=\"(.*?)\"") - s + Regex.find Regex.All linkPattern s |> List.map .submatches |> List.map toTuples |> Maybe.Extra.values |> Dict.fromList + + +linkPattern : Regex.Regex +linkPattern = + Regex.regex "<(.*?)>; rel=\"(.*?)\""