summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2018-01-28 17:00:33 +0000
committerGitHub <noreply@github.com>2018-01-28 17:00:33 +0000
commit6c035379fef205a4a1e5b12f7df6618750a3ba53 (patch)
tree3f09ad2436241c17fe4bd7945e77c547d2e56a87 /lib
parentad222e3015841f4e57bf3f75d809b00082b91a3a (diff)
parenta20326e2682486be95c33cf5cb23fe1cafe70979 (diff)
downloadNim-6c035379fef205a4a1e5b12f7df6618750a3ba53.tar.gz
Merge pull request #6597 from pgkos/uri-allow-no-authority
Allow parsing URIs without authority
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/uri.nim14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim
index a651530c3..d2d11253a 100644
--- a/lib/pure/uri.nim
+++ b/lib/pure/uri.nim
@@ -178,9 +178,8 @@ proc parseUri*(uri: string, result: var Uri) =
     i.inc(2) # Skip //
     var authority = ""
     i.inc parseUntil(uri, authority, {'/', '?', '#'}, i)
-    if authority == "":
-      raise newException(ValueError, "Expected authority got nothing.")
-    parseAuthority(authority, result)
+    if authority.len > 0:
+      parseAuthority(authority, result)
   else:
     result.opaque = true
 
@@ -465,6 +464,15 @@ when isMainModule:
     doAssert test.hostname == "github.com"
     doAssert test.port == "dom96"
     doAssert test.path == "/packages"
+    
+  block:
+    let str = "file:///foo/bar/baz.txt"
+    let test = parseUri(str)
+    doAssert test.scheme == "file"
+    doAssert test.username == ""
+    doAssert test.hostname == ""
+    doAssert test.port == ""
+    doAssert test.path == "/foo/bar/baz.txt"
 
   # Remove dot segments tests
   block: