From 1dc6caea6b449a0d4e9334ff19aa7d6484c3528f Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Fri, 13 Oct 2017 20:10:54 +0100 Subject: Fixes issues with URI concatenation when URI has no path. --- lib/pure/uri.nim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/pure/uri.nim') 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 -- cgit 1.4.1-2-gfad0 From 6a3288a60e78c9b17f2640fff20ab94969914974 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 29 Oct 2017 08:55:30 +0100 Subject: more replacements for the deprecated '<' --- lib/core/macros.nim | 6 +++--- lib/deprecated/pure/actors.nim | 6 +++--- lib/pure/collections/critbits.nim | 2 +- lib/pure/collections/tableimpl.nim | 2 +- lib/pure/concurrency/threadpool.nim | 4 ++-- lib/pure/future.nim | 6 +++--- lib/pure/json.nim | 16 ++++++++-------- lib/pure/marshal.nim | 2 +- lib/pure/selectors.nim | 4 ++-- lib/pure/strutils.nim | 6 +++--- lib/pure/uri.nim | 2 +- lib/system/debugger.nim | 2 +- lib/system/gc.nim | 6 +++--- lib/system/gc2.nim | 6 +++--- lib/system/gc_ms.nim | 4 ++-- lib/system/repr.nim | 2 +- lib/system/reprjs.nim | 6 +++--- lib/system/sysstr.nim | 2 +- lib/wrappers/openssl.nim | 2 +- 19 files changed, 43 insertions(+), 43 deletions(-) (limited to 'lib/pure/uri.nim') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 22c479a4a..d3f541153 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -839,7 +839,7 @@ proc newNilLit*(): NimNode {.compileTime.} = ## New nil literal shortcut result = newNimNode(nnkNilLit) -proc last*(node: NimNode): NimNode {.compileTime.} = node[`*(p, b: untyped): untyped = if c[0].kind == nnkIdent and c[0].ident == !"->": var procTy = createProcType(c[1], c[2]) params[0] = procTy[0][0] - for i in 1 .. ) got (" & $c[0].ident & ").") @@ -96,7 +96,7 @@ macro `=>`*(p, b: untyped): untyped = if p[0].kind == nnkIdent and p[0].ident == !"->": var procTy = createProcType(p[1], p[2]) params[0] = procTy[0][0] - for i in 1 .. ) got (" & $p[0].ident & ").") diff --git a/lib/pure/json.nim b/lib/pure/json.nim index fd7a3af03..3d86cc9d7 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -823,13 +823,13 @@ proc toJson(x: NimNode): NimNode {.compiletime.} = of nnkBracket: # array if x.len == 0: return newCall(bindSym"newJArray") result = newNimNode(nnkBracket) - for i in 0 .. s.len: return -1 - + if sub.len == 1: return find(s, sub[0], start, last) - + var a {.noinit.}: SkipTable initSkipTable(a, sub) result = find(a, s, sub, start, last) diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim index 4b2e4e052..c702b054c 100644 --- a/lib/pure/uri.nim +++ b/lib/pure/uri.nim @@ -250,7 +250,7 @@ proc combine*(base: Uri, reference: Uri): Uri = proc combine*(uris: varargs[Uri]): Uri = ## Combines multiple URIs together. result = uris[0] - for i in 1 .. 0 : add(result, ", ") # advance pointer and point to element at index @@ -192,7 +192,7 @@ proc reprRecordAux(result: var string, o: pointer, typ: PNimType, cl: var ReprCl reprAux(result, val, typ.node.typ, cl) else: # if the object has more than one field, sons is not nil and contains the fields. - for i in 0 ..