renamed URLencode to encodeUrl
This commit is contained in:
parent
758d8e11d9
commit
9500780037
3 changed files with 11 additions and 10 deletions
|
|
@ -374,11 +374,11 @@ proc genItem(d: PDoc, n, nameNode: PNode, k: TSymKind) =
|
||||||
cleanPlainSymbol = renderPlainSymbolName(nameNode)
|
cleanPlainSymbol = renderPlainSymbolName(nameNode)
|
||||||
complexSymbol = complexName(k, n, cleanPlainSymbol)
|
complexSymbol = complexName(k, n, cleanPlainSymbol)
|
||||||
plainSymbolRope = toRope(cleanPlainSymbol)
|
plainSymbolRope = toRope(cleanPlainSymbol)
|
||||||
plainSymbolEncRope = toRope(urlEncode(cleanPlainSymbol))
|
plainSymbolEncRope = toRope(encodeUrl(cleanPlainSymbol))
|
||||||
itemIDRope = toRope(d.id)
|
itemIDRope = toRope(d.id)
|
||||||
symbolOrId = d.newUniquePlainSymbol(complexSymbol)
|
symbolOrId = d.newUniquePlainSymbol(complexSymbol)
|
||||||
symbolOrIdRope = symbolOrId.toRope
|
symbolOrIdRope = symbolOrId.toRope
|
||||||
symbolOrIdEncRope = urlEncode(symbolOrId).toRope
|
symbolOrIdEncRope = encodeUrl(symbolOrId).toRope
|
||||||
|
|
||||||
var seeSrcRope: PRope = nil
|
var seeSrcRope: PRope = nil
|
||||||
let docItemSeeSrc = getConfigVar("doc.item.seesrc")
|
let docItemSeeSrc = getConfigVar("doc.item.seesrc")
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
import strutils, os, strtabs, cookies
|
import strutils, os, strtabs, cookies
|
||||||
|
|
||||||
proc urlEncode*(s: string): string =
|
proc encodeUrl*(s: string): string =
|
||||||
## Encodes a value to be HTTP safe: This means that characters in the set
|
## Encodes a value to be HTTP safe: This means that characters in the set
|
||||||
## ``{'A'..'Z', 'a'..'z', '0'..'9', '_'}`` are carried over to the result,
|
## ``{'A'..'Z', 'a'..'z', '0'..'9', '_'}`` are carried over to the result,
|
||||||
## a space is converted to ``'+'`` and every other character is encoded as
|
## a space is converted to ``'+'`` and every other character is encoded as
|
||||||
|
|
@ -52,7 +52,7 @@ proc handleHexChar(c: char, x: var int) {.inline.} =
|
||||||
of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
|
of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
|
||||||
else: assert(false)
|
else: assert(false)
|
||||||
|
|
||||||
proc urlDecode*(s: string): string =
|
proc decodeUrl*(s: string): string =
|
||||||
## Decodes a value from its HTTP representation: This means that a ``'+'``
|
## Decodes a value from its HTTP representation: This means that a ``'+'``
|
||||||
## is converted to a space, ``'%xx'`` (where ``xx`` denotes a hexadecimal
|
## is converted to a space, ``'%xx'`` (where ``xx`` denotes a hexadecimal
|
||||||
## value) is converted to the character with ordinal number ``xx``, and
|
## value) is converted to the character with ordinal number ``xx``, and
|
||||||
|
|
@ -74,6 +74,8 @@ proc urlDecode*(s: string): string =
|
||||||
inc(j)
|
inc(j)
|
||||||
setLen(result, j)
|
setLen(result, j)
|
||||||
|
|
||||||
|
{.deprecated: [URLDecode: decodeUrl, URLEncode: encodeUrl].}
|
||||||
|
|
||||||
proc addXmlChar(dest: var string, c: char) {.inline.} =
|
proc addXmlChar(dest: var string, c: char) {.inline.} =
|
||||||
case c
|
case c
|
||||||
of '&': add(dest, "&")
|
of '&': add(dest, "&")
|
||||||
|
|
@ -100,7 +102,7 @@ type
|
||||||
methodGet ## query uses the GET method
|
methodGet ## query uses the GET method
|
||||||
|
|
||||||
{.deprecated: [TRequestMethod: RequestMethod, ECgi: CgiError,
|
{.deprecated: [TRequestMethod: RequestMethod, ECgi: CgiError,
|
||||||
URLencode: urlEncode, XMLencode: xmlEncode, URLdecode: urlDecode].}
|
XMLencode: xmlEncode].}
|
||||||
|
|
||||||
proc cgiError*(msg: string) {.noreturn.} =
|
proc cgiError*(msg: string) {.noreturn.} =
|
||||||
## raises an ECgi exception with message `msg`.
|
## raises an ECgi exception with message `msg`.
|
||||||
|
|
@ -332,9 +334,9 @@ proc setTestData*(keysvalues: varargs[string]) =
|
||||||
var i = 0
|
var i = 0
|
||||||
var query = ""
|
var query = ""
|
||||||
while i < keysvalues.len:
|
while i < keysvalues.len:
|
||||||
add(query, urlEncode(keysvalues[i]))
|
add(query, encodeUrl(keysvalues[i]))
|
||||||
add(query, '=')
|
add(query, '=')
|
||||||
add(query, urlEncode(keysvalues[i+1]))
|
add(query, encodeUrl(keysvalues[i+1]))
|
||||||
add(query, '&')
|
add(query, '&')
|
||||||
inc(i, 2)
|
inc(i, 2)
|
||||||
putEnv("QUERY_STRING", query)
|
putEnv("QUERY_STRING", query)
|
||||||
|
|
@ -394,5 +396,5 @@ proc existsCookie*(name: string): bool =
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
const test1 = "abc\L+def xyz"
|
const test1 = "abc\L+def xyz"
|
||||||
assert URLencode(test1) == "abc%0A%2Bdef+xyz"
|
assert encodeUrl(test1) == "abc%0A%2Bdef+xyz"
|
||||||
assert URLdecode(URLencode(test1)) == test1
|
assert decodeUrl(encodeUrl(test1)) == test1
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -3,7 +3,6 @@ version 0.10
|
||||||
|
|
||||||
- Test nimfix on various babel packages
|
- Test nimfix on various babel packages
|
||||||
- Pegs do not work at compile-time
|
- Pegs do not work at compile-time
|
||||||
- rename cgi.URLencode to encodeUrl
|
|
||||||
|
|
||||||
|
|
||||||
version 0.9.6
|
version 0.9.6
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue