1module Sources.Services.Common exposing (cleanPath, noPrep)
2
3import Sources exposing (..)
4import Sources.Processing exposing (..)
5import String.Ext as String
6import Time
7
8
9
10-- PATHS
11
12
13{-| Clean a path.
14
15 >>> cleanPath " "
16 ""
17
18 >>> cleanPath "/example"
19 "example/"
20
21 >>> cleanPath "example"
22 "example/"
23
24 >>> cleanPath "example/"
25 "example/"
26
27-}
28cleanPath : String -> String
29cleanPath dirtyPath =
30 dirtyPath
31 |> String.trim
32 |> String.chopStart "/"
33 |> String.chopEnd "/"
34 |> (\p ->
35 if String.isEmpty p then
36 p
37
38 else
39 p ++ "/"
40 )
41
42
43
44-- PARSING
45
46
47noPrep : String -> Time.Posix -> SourceData -> Marker -> PrepationAnswer Marker
48noPrep _ _ srcData _ =
49 { sourceData = srcData, marker = TheEnd }