Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme parse() section for URL decoding #168

Merged
merged 2 commits into from Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
lukeed marked this conversation as resolved.
Show resolved Hide resolved

```js
const app = polka();
const { parse } = require('@polka/url');
app.parse = (req, toDecode) => {
lukeed marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -140,6 +150,8 @@ app.parse = require('parseurl');
//=> Done!
```

> **Note:** `parseurl` doesn't support URL decoding yet.

### listen()

Returns: `Polka`
Expand Down