Skip to content

Commit

Permalink
#164 added automatic URL decoding (#166)
Browse files Browse the repository at this point in the history
* #164 added URL decoding to path and query params

* #164 updated changelog + version bump

* #164 Removed superfluous isSome-operation

* Update src/prologue/core/context.nim

Co-authored-by: Philipp Doerner <[email protected]>
Co-authored-by: flywind <[email protected]>
  • Loading branch information
3 people authored May 28, 2022
1 parent dfcaeef commit e456548
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.0

Added automatic URL decoding when fetching query parameters or path parameters from request object

## 0.5.8

remove cursor annotation; Prologue should work with ORC (thanks to @Yardanico's advice)
Expand Down
2 changes: 1 addition & 1 deletion prologue.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.5.8"
version = "0.6.0"
author = "flywind"
description = "Prologue is an elegant and high performance web framework"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/prologue/core/constants.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const
PrologueVersion* = "0.5.8" ## The current version of Prologue.
PrologueVersion* = "0.6.0" ## The current version of Prologue.
ProloguePrefix* = "PROLOGUE" ## The helper prefix for environment variables.
useAsyncHTTPServer* = defined(windows) or defined(usestd) ## Uses `asynchttpserver`.
4 changes: 2 additions & 2 deletions src/prologue/core/context.nim
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func getQueryParamsOption*(ctx: Context, key: string): Option[string] {.inline.}
## Gets a param from the query strings. Returns none(string) if the param does not exist.
## (for example, "www.google.com/hello?name=12", `name=12`).
let hasQueryParam = ctx.request.queryParams.hasKey(key)
result = if hasQueryParam: some(ctx.request.queryParams[key]) else: none(string)
result = if hasQueryParam: some(decodeUrl(ctx.request.queryParams[key])) else: none(string)

func getQueryParams*(ctx: Context, key: string, default = ""): string {.inline.} =
## Gets a param from the query strings(for example, "www.google.com/hello?name=12", `name=12`).
Expand All @@ -365,7 +365,7 @@ func getPathParamsOption*(ctx: Context, key: string): Option[string] {.inline.}
## Gets a route parameter(for example, "/hello/{name}"). Returns none(string)
## if the param does not exist.
let hasPathParam = ctx.request.pathParams.hasKey(key)
result = if hasPathParam: some(ctx.request.pathParams[key]) else: none(string)
result = if hasPathParam: some(decodeUrl(ctx.request.pathParams[key])) else: none(string)

func getPathParams*(ctx: Context, key: string): string {.inline.} =
## Gets the route parameters(for example, "/hello/{name}"). Returns an empty
Expand Down

0 comments on commit e456548

Please sign in to comment.