From 2a5277ab68bde7d73bc1c767f039961f9f25f94f Mon Sep 17 00:00:00 2001 From: SelvarajKarupusamy Date: Wed, 23 Jun 2021 14:53:56 +0530 Subject: [PATCH 1/2] Update readme parse() section for URL decoding --- readme.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 2228ca8..a500ff4 100644 --- a/readme.md +++ b/readme.md @@ -126,12 +126,22 @@ You may also pass a sub-application, which _must_ be accompanied by a `base` pat Please see [`Middleware`](#middleware) and [Express' middleware examples](http://expressjs.com/en/4x/api.html#middleware-callback-function-examples) for more info. -### parse(req) +### parse(req, toDecode=true) Returns: `Object` or `undefined` As of `v0.5.0`, this is an alias of the [`@polka/url`](/packages/url) module. For nearly all cases, you'll notice no changes. +One important difference is that URL decoding is enabled by default in polka but it is disabled by default in the `@polka/url` module. You can disable the URL decoding if required, + +```js +const app = polka(); +const parse = require('@polka/url'); +app.parse = (req, toDecode) => { + return parse(req, false); // or simply, return parse(req); +} +``` + But, for whatever reason, you can quickly swap in [`parseurl`](https://github.com/pillarjs/parseurl) again: ```js @@ -140,6 +150,8 @@ app.parse = require('parseurl'); //=> Done! ``` +> **Note:** `parseurl` doesn't support URL decoding yet. + ### listen() Returns: `Polka` From f84dbe3c1def290b5ab108457bba79d6d14bc59b Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Wed, 11 Aug 2021 11:47:46 -0700 Subject: [PATCH 2/2] Update readme.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a500ff4..62f2380 100644 --- a/readme.md +++ b/readme.md @@ -136,7 +136,7 @@ One important difference is that URL decoding is enabled by default in polka but ```js const app = polka(); -const parse = require('@polka/url'); +const { parse } = require('@polka/url'); app.parse = (req, toDecode) => { return parse(req, false); // or simply, return parse(req); }