File tree Expand file tree Collapse file tree 3 files changed +13
-30
lines changed
examples/end-to-end/script/src Expand file tree Collapse file tree 3 files changed +13
-30
lines changed Original file line number Diff line number Diff line change @@ -86,11 +86,11 @@ runTests =
8686 , test " absolute detection handles POSIX, UNC, and Windows" <|
8787 \ () ->
8888 Expect . all
89- [ \ _ -> Expect . equal True ( FilePath . fromString " /foo" |> FilePath . Internal . isAbsolute)
90- , \ _ -> Expect . equal True ( FilePath . fromString " //server/share" |> FilePath . Internal . isAbsolute)
91- , \ _ -> Expect . equal True ( FilePath . fromString " C:/foo" |> FilePath . Internal . isAbsolute)
92- , \ _ -> Expect . equal False ( FilePath . fromString " C:foo" |> FilePath . Internal . isAbsolute)
93- , \ _ -> Expect . equal False ( FilePath . fromString " ../foo" |> FilePath . Internal . isAbsolute)
89+ [ \ _ -> Expect . equal True ( FilePath . fromString " /foo" |> FilePath . toString |> FilePath . Internal . isAbsolute)
90+ , \ _ -> Expect . equal True ( FilePath . fromString " //server/share" |> FilePath . toString |> FilePath . Internal . isAbsolute)
91+ , \ _ -> Expect . equal True ( FilePath . fromString " C:/foo" |> FilePath . toString |> FilePath . Internal . isAbsolute)
92+ , \ _ -> Expect . equal False ( FilePath . fromString " C:foo" |> FilePath . toString |> FilePath . Internal . isAbsolute)
93+ , \ _ -> Expect . equal False ( FilePath . fromString " ../foo" |> FilePath . toString |> FilePath . Internal . isAbsolute)
9494 ]
9595 ()
9696 |> BackendTask . succeed
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import BackendTask.Http
3737import BackendTask.Internal.Request
3838import Char
3939import FatalError exposing (FatalError )
40+ import FilePath.Internal
4041import Json.Decode as Decode
4142import Json.Encode as Encode
4243
@@ -151,7 +152,7 @@ append basePath nextPath =
151152 { root = baseParsed. root
152153 , pathSegments =
153154 normalizePathSegments
154- ( isAbsoluteRoot baseParsed. root)
155+ ( FilePath . Internal . isAbsolute baseParsed. root)
155156 ( baseParsed. pathSegments ++ nextParsed. pathSegments)
156157 }
157158 )
@@ -319,22 +320,10 @@ parse (FilePath rawPath) =
319320 , pathSegments =
320321 withoutRoot
321322 |> String . split " /"
322- |> normalizePathSegments ( isAbsoluteRoot root)
323+ |> normalizePathSegments ( FilePath . Internal . isAbsolute root)
323324 }
324325
325326
326- isAbsoluteRoot : String -> Bool
327- isAbsoluteRoot root =
328- case root of
329- " /" ->
330- True
331-
332- " //" ->
333- True
334-
335- _ ->
336- String . endsWith " :/" root
337-
338327
339328normalizePathSegments : Bool -> List String -> List String
340329normalizePathSegments hasAbsoluteRoot rawSegments =
Original file line number Diff line number Diff line change 11module FilePath.Internal exposing (isAbsolute )
22
33import Char
4- import FilePath exposing (FilePath )
54
65
7- {- | Whether this path is absolute. Package-internal only — not exposed to consumers.
6+ {- | Whether a path string represents an absolute path. Package-internal only — not
7+ exposed to consumers.
88
9- Checks the normalized string prefix, which is equivalent to checking the parsed root
10- since `FilePath.fromString` guarantees consistent formatting:
9+ Works on the normalized string form produced by `FilePath.toString`:
1110
1211 - `/...` → POSIX absolute
1312 - `//...` → UNC absolute
1413 - `X:/...` → Windows drive absolute
1514
1615-}
17- isAbsolute : FilePath -> Bool
18- isAbsolute filePath =
19- let
20- str : String
21- str =
22- FilePath . toString filePath
23- in
16+ isAbsolute : String -> Bool
17+ isAbsolute str =
2418 String . startsWith " /" str
2519 || hasAbsoluteDriveRoot str
2620
You can’t perform that action at this time.
0 commit comments