diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2017-10-13 20:10:54 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2017-10-13 20:10:54 +0100 |
commit | 1dc6caea6b449a0d4e9334ff19aa7d6484c3528f (patch) | |
tree | 2aa54c47d274bfcf2fc2a91930e2bd89c5c56bab /lib | |
parent | 5dca695bcfaad7212679c80b3219e0f69afdca7d (diff) | |
download | Nim-1dc6caea6b449a0d4e9334ff19aa7d6484c3528f.tar.gz |
Fixes issues with URI concatenation when URI has no path.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/uri.nim | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim index d8e4ed52f..4b2e4e052 100644 --- a/lib/pure/uri.nim +++ b/lib/pure/uri.nim @@ -278,7 +278,9 @@ proc `/`*(x: Uri, path: string): Uri = result = x if result.path.len == 0: - result.path = path + if path[0] != '/': + result.path = "/" + result.path.add(path) return if result.path[result.path.len-1] == '/': @@ -476,6 +478,11 @@ when isMainModule: let foo = parseUri("http://example.com") / "/baz" doAssert foo.path == "/baz" + # bug found on stream 13/10/17 + block: + let foo = parseUri("http://localhost:9515") / "status" + doAssert $foo == "http://localhost:9515/status" + # isAbsolute tests block: doAssert "www.google.com".parseUri().isAbsolute() == false @@ -515,4 +522,6 @@ when isMainModule: doAssert "https://example.com/about".parseUri().isAbsolute == true doAssert "https://example.com/about/staff.html".parseUri().isAbsolute == true doAssert "https://example.com/about/staff.html?".parseUri().isAbsolute == true - doAssert "https://example.com/about/staff.html?parameters".parseUri().isAbsolute == true \ No newline at end of file + doAssert "https://example.com/about/staff.html?parameters".parseUri().isAbsolute == true + + echo("All good!") \ No newline at end of file |