mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +00:00
Fix some deprecation warnings in the uri module.
This commit is contained in:
@@ -19,14 +19,14 @@ type
|
||||
|
||||
{.deprecated: [TUrl: Url, TUri: Uri].}
|
||||
|
||||
proc `$`*(url: TUrl): string {.deprecated.} =
|
||||
## **Deprecated since 0.9.6**: Use ``TUri`` instead.
|
||||
proc `$`*(url: Url): string {.deprecated.} =
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
return string(url)
|
||||
|
||||
proc `/`*(a, b: TUrl): TUrl {.deprecated.} =
|
||||
proc `/`*(a, b: Url): Url {.deprecated.} =
|
||||
## 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 bS = $b
|
||||
if urlS == "": return b
|
||||
@@ -36,15 +36,15 @@ proc `/`*(a, b: TUrl): TUrl {.deprecated.} =
|
||||
urlS.add(bS.substr(1))
|
||||
else:
|
||||
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.
|
||||
##
|
||||
## **Deprecated since 0.9.6**: Use ``TUri`` instead.
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
url = url / a
|
||||
|
||||
proc parseAuthority(authority: string, result: var TUri) =
|
||||
proc parseAuthority(authority: string, result: var Uri) =
|
||||
var i = 0
|
||||
var inPort = false
|
||||
while true:
|
||||
@@ -65,7 +65,7 @@ proc parseAuthority(authority: string, result: var TUri) =
|
||||
result.hostname.add(authority[i])
|
||||
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)
|
||||
|
||||
@@ -82,11 +82,11 @@ proc parsePath(uri: string, i: var int, result: var TUri) =
|
||||
i.inc # Skip '#'
|
||||
i.inc parseUntil(uri, result.anchor, {}, i)
|
||||
|
||||
proc initUri(): TUri =
|
||||
result = TUri(scheme: "", username: "", password: "", hostname: "", port: "",
|
||||
proc initUri(): Uri =
|
||||
result = Uri(scheme: "", username: "", password: "", hostname: "", port: "",
|
||||
path: "", query: "", anchor: "")
|
||||
|
||||
proc parseUri*(uri: string): TUri =
|
||||
proc parseUri*(uri: string): Uri =
|
||||
## Parses a URI.
|
||||
result = initUri()
|
||||
|
||||
@@ -150,7 +150,7 @@ proc removeDotSegments(path: string): string =
|
||||
result = collection.join("/")
|
||||
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
|
||||
if base.hostname != "" and base.path == "":
|
||||
'/' & reference.path
|
||||
@@ -161,7 +161,7 @@ proc merge(base, reference: TUri): string =
|
||||
else:
|
||||
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.
|
||||
##
|
||||
## This uses the algorithm specified in
|
||||
@@ -216,13 +216,13 @@ proc combine*(base: TUri, reference: TUri): TUri =
|
||||
result.scheme = base.scheme
|
||||
result.anchor = reference.anchor
|
||||
|
||||
proc combine*(uris: varargs[TUri]): TUri =
|
||||
proc combine*(uris: varargs[Uri]): Uri =
|
||||
## Combines multiple URIs together.
|
||||
result = uris[0]
|
||||
for i in 1 .. <uris.len:
|
||||
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.
|
||||
##
|
||||
## 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(path)
|
||||
|
||||
proc `$`*(u: TUri): string =
|
||||
proc `$`*(u: Uri): string =
|
||||
## Returns the string representation of the specified URI object.
|
||||
result = ""
|
||||
if u.scheme.len > 0:
|
||||
|
||||
Reference in New Issue
Block a user