Fix some deprecation warnings in the uri module.
This commit is contained in:
parent
9df1de44f6
commit
342ed97eed
1 changed files with 17 additions and 17 deletions
|
|
@ -19,14 +19,14 @@ type
|
||||||
|
|
||||||
{.deprecated: [TUrl: Url, TUri: Uri].}
|
{.deprecated: [TUrl: Url, TUri: Uri].}
|
||||||
|
|
||||||
proc `$`*(url: TUrl): string {.deprecated.} =
|
proc `$`*(url: Url): string {.deprecated.} =
|
||||||
## **Deprecated since 0.9.6**: Use ``TUri`` instead.
|
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||||
return string(url)
|
return string(url)
|
||||||
|
|
||||||
proc `/`*(a, b: TUrl): TUrl {.deprecated.} =
|
proc `/`*(a, b: Url): Url {.deprecated.} =
|
||||||
## Joins two URLs together, separating them with / if needed.
|
## Joins two URLs together, separating them with / if needed.
|
||||||
##
|
##
|
||||||
## **Deprecated since 0.9.6**: Use ``TUri`` instead.
|
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||||
var urlS = $a
|
var urlS = $a
|
||||||
var bS = $b
|
var bS = $b
|
||||||
if urlS == "": return b
|
if urlS == "": return b
|
||||||
|
|
@ -36,15 +36,15 @@ proc `/`*(a, b: TUrl): TUrl {.deprecated.} =
|
||||||
urlS.add(bS.substr(1))
|
urlS.add(bS.substr(1))
|
||||||
else:
|
else:
|
||||||
urlS.add(bs)
|
urlS.add(bs)
|
||||||
result = TUrl(urlS)
|
result = Url(urlS)
|
||||||
|
|
||||||
proc add*(url: var TUrl, a: TUrl) {.deprecated.} =
|
proc add*(url: var Url, a: Url) {.deprecated.} =
|
||||||
## Appends url to url.
|
## Appends url to url.
|
||||||
##
|
##
|
||||||
## **Deprecated since 0.9.6**: Use ``TUri`` instead.
|
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||||
url = url / a
|
url = url / a
|
||||||
|
|
||||||
proc parseAuthority(authority: string, result: var TUri) =
|
proc parseAuthority(authority: string, result: var Uri) =
|
||||||
var i = 0
|
var i = 0
|
||||||
var inPort = false
|
var inPort = false
|
||||||
while true:
|
while true:
|
||||||
|
|
@ -65,7 +65,7 @@ proc parseAuthority(authority: string, result: var TUri) =
|
||||||
result.hostname.add(authority[i])
|
result.hostname.add(authority[i])
|
||||||
i.inc
|
i.inc
|
||||||
|
|
||||||
proc parsePath(uri: string, i: var int, result: var TUri) =
|
proc parsePath(uri: string, i: var int, result: var Uri) =
|
||||||
|
|
||||||
i.inc parseUntil(uri, result.path, {'?', '#'}, i)
|
i.inc parseUntil(uri, result.path, {'?', '#'}, i)
|
||||||
|
|
||||||
|
|
@ -82,11 +82,11 @@ proc parsePath(uri: string, i: var int, result: var TUri) =
|
||||||
i.inc # Skip '#'
|
i.inc # Skip '#'
|
||||||
i.inc parseUntil(uri, result.anchor, {}, i)
|
i.inc parseUntil(uri, result.anchor, {}, i)
|
||||||
|
|
||||||
proc initUri(): TUri =
|
proc initUri(): Uri =
|
||||||
result = TUri(scheme: "", username: "", password: "", hostname: "", port: "",
|
result = Uri(scheme: "", username: "", password: "", hostname: "", port: "",
|
||||||
path: "", query: "", anchor: "")
|
path: "", query: "", anchor: "")
|
||||||
|
|
||||||
proc parseUri*(uri: string): TUri =
|
proc parseUri*(uri: string): Uri =
|
||||||
## Parses a URI.
|
## Parses a URI.
|
||||||
result = initUri()
|
result = initUri()
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ proc removeDotSegments(path: string): string =
|
||||||
result = collection.join("/")
|
result = collection.join("/")
|
||||||
if endsWithSlash: result.add '/'
|
if endsWithSlash: result.add '/'
|
||||||
|
|
||||||
proc merge(base, reference: TUri): string =
|
proc merge(base, reference: Uri): string =
|
||||||
# http://tools.ietf.org/html/rfc3986#section-5.2.3
|
# http://tools.ietf.org/html/rfc3986#section-5.2.3
|
||||||
if base.hostname != "" and base.path == "":
|
if base.hostname != "" and base.path == "":
|
||||||
'/' & reference.path
|
'/' & reference.path
|
||||||
|
|
@ -161,7 +161,7 @@ proc merge(base, reference: TUri): string =
|
||||||
else:
|
else:
|
||||||
base.path[0 .. lastSegment] & reference.path
|
base.path[0 .. lastSegment] & reference.path
|
||||||
|
|
||||||
proc combine*(base: TUri, reference: TUri): TUri =
|
proc combine*(base: Uri, reference: Uri): Uri =
|
||||||
## Combines a base URI with a reference URI.
|
## Combines a base URI with a reference URI.
|
||||||
##
|
##
|
||||||
## This uses the algorithm specified in
|
## This uses the algorithm specified in
|
||||||
|
|
@ -216,13 +216,13 @@ proc combine*(base: TUri, reference: TUri): TUri =
|
||||||
result.scheme = base.scheme
|
result.scheme = base.scheme
|
||||||
result.anchor = reference.anchor
|
result.anchor = reference.anchor
|
||||||
|
|
||||||
proc combine*(uris: varargs[TUri]): TUri =
|
proc combine*(uris: varargs[Uri]): Uri =
|
||||||
## Combines multiple URIs together.
|
## Combines multiple URIs together.
|
||||||
result = uris[0]
|
result = uris[0]
|
||||||
for i in 1 .. <uris.len:
|
for i in 1 .. <uris.len:
|
||||||
result = combine(result, uris[i])
|
result = combine(result, uris[i])
|
||||||
|
|
||||||
proc `/`*(x: TUri, path: string): TUri =
|
proc `/`*(x: Uri, path: string): Uri =
|
||||||
## Concatenates the path specified to the specified URI's path.
|
## Concatenates the path specified to the specified URI's path.
|
||||||
##
|
##
|
||||||
## Contrary to the ``combine`` procedure you do not have to worry about
|
## Contrary to the ``combine`` procedure you do not have to worry about
|
||||||
|
|
@ -251,7 +251,7 @@ proc `/`*(x: TUri, path: string): TUri =
|
||||||
result.path.add '/'
|
result.path.add '/'
|
||||||
result.path.add(path)
|
result.path.add(path)
|
||||||
|
|
||||||
proc `$`*(u: TUri): string =
|
proc `$`*(u: Uri): string =
|
||||||
## Returns the string representation of the specified URI object.
|
## Returns the string representation of the specified URI object.
|
||||||
result = ""
|
result = ""
|
||||||
if u.scheme.len > 0:
|
if u.scheme.len > 0:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue