file-uri-0.1.0.0: File URI parsing
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.URI.File.Internal

Synopsis

Documentation

>>> :set -XOverloadedStrings

data FileURI Source #

A parsed file URI. It can have an auth/host part.

Constructors

FileURI 

Fields

Instances

Instances details
Show FileURI Source # 
Instance details

Defined in System.URI.File.Internal

Eq FileURI Source # 
Instance details

Defined in System.URI.File.Internal

Methods

(==) :: FileURI -> FileURI -> Bool #

(/=) :: FileURI -> FileURI -> Bool #

data ParseSyntax Source #

RFC syntax configuration.

Constructors

StrictPosix

Only parses the strict syntax according to section 2 of RFC 8089, which is technically posix paths.

ExtendedPosix

Also parses extended user information described in E.1

ExtendedWindows

Parses windows paths according to E.1, E.2 and E.3. Unlike the spec, posix paths are rejected.

Instances

Instances details
Show ParseSyntax Source # 
Instance details

Defined in System.URI.File.Internal

Eq ParseSyntax Source # 
Instance details

Defined in System.URI.File.Internal

parseFileURI Source #

Arguments

:: ParseSyntax

RFC syntax configuration

-> ByteString

input file URI

-> Either String FileURI 

Parse a file URI such as file:///foo/bar into FileURI.

>>> parseFileURI StrictPosix "file:/path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
>>> parseFileURI StrictPosix "file:///path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
>>> parseFileURI StrictPosix "file://hostname/path/to/file"
Right (FileURI {fileAuth = Just "hostname", filePath = "/path/to/file"})
>>> parseFileURI StrictPosix "file://localhost/path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
>>> parseFileURI StrictPosix "http://localhost/path/to/file"
Left "string"
>>> parseFileURI StrictPosix "/path/to/file"
Left "string"
>>> parseFileURI ExtendedWindows "file://///host.example.com/path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "//host.example.com/path/to/file"})
>>> parseFileURI ExtendedWindows "file:///c:/path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
>>> parseFileURI ExtendedWindows "file:/c:/path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
>>> parseFileURI ExtendedWindows "file:c:/path/to/file"
Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})

fileURIStrictP :: Parser FileURI Source #

Parse a file URI according to the main ABNF in RFC 8089, without any extended rules, which is as follows:

   file-URI       = file-scheme ":" file-hier-part

   file-scheme    = "file"

   file-hier-part = ( "//" auth-path )
                  / local-path

   auth-path      = [ file-auth ] path-absolute

   local-path     = path-absolute

   file-auth      = "localhost"
                  / host

fileURIExtendedPosixP :: Parser FileURI Source #

Parse a file URI according to the main ABNF in RFC 8089, with extended rule E.1.

   file-URI       = file-scheme ":" file-hier-part

   file-scheme    = "file"

   file-hier-part = ( "//" auth-path )
                  / local-path

   auth-path      = [ file-auth ] path-absolute

   local-path     = path-absolute

   file-auth      = "localhost"
                  / [ userinfo "@" ] host

fileURIExtendedWindowsP :: Parser FileURI Source #

Parse a file URI according for windows according to E.1, E.2 and E.3. Unlike the spec, posix paths are rejected. The ABNF is a slight modification of Appendix F.

   file-URI       = file-scheme ":" file-hier-part

   file-scheme    = "file"

   file-hier-part = ( "//" auth-path )
                  / local-path

   auth-path      = [ file-auth ] file-absolute
                  / unc-authority path-absolute

   local-path     =  drive-letter path-absolute
                  / file-absolute

   file-auth      = "localhost"
                  / [ userinfo "@" ] host

   unc-authority  = 2*3"/" file-host

   file-host      = inline-IP  IPv4address  reg-name

   inline-IP      = "%5B" ( IPv6address / IPvFuture ) "%5D"

   file-absolute  = "/" drive-letter path-absolute

   drive-letter   = ALPHA ":"
                  / ALPHA "|"

ipVFutureP :: Parser ByteString Source #

Parses IPVFuture addresses. See relevant section in RFC.

ipV6P :: Parser ByteString Source #

Parses IPV6 addresses. See relevant section in RFC.

ipV4P :: Parser ByteString Source #

Parses a valid IPV4 address

parseBetween :: (Alternative m, Monad m) => Int -> Int -> m a -> m [a] Source #