uri: document removeDotSegments, add tests, show failure modes (#17064)

* uri: document removeDotSegments, add tests, show failure modes
* address comments
This commit is contained in:
Timothee Cour 2021-02-20 08:58:54 -08:00 • committed by GitHub
commit 0fcf1af765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 9 deletions

View file

@ -1,10 +1,8 @@
discard """
targets: "c js"
joinable: false # because of `include uri`
"""
# import std/uri # pending https://github.com/nim-lang/Nim/pull/11865
include uri # because of `removeDotSegments`
import std/uri
from std/sequtils import toSeq
template main() =
@ -171,11 +169,6 @@ template main() =
let test = parseUri("http://example.com/foo/") / "/bar/asd"
doAssert test.path == "/foo/bar/asd"
block: # removeDotSegments
doAssert removeDotSegments("/foo/bar/baz") == "/foo/bar/baz"
doAssert removeDotSegments("") == "" # empty test
doAssert removeDotSegments(".") == "." # trailing period
block: # bug #3207
doAssert parseUri("http://qq/1").combine(parseUri("https://qqq")).`$` == "https://qqq"