From: Eduardo San Martin Morote Date: Wed, 7 Oct 2020 14:46:29 +0000 (+0200) Subject: docs: note about plus character in query X-Git-Tag: v4.0.0-rc.1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ccf1653c7b1f5b71ad378b8dc54a9c800dfaef6;p=thirdparty%2Fvuejs%2Frouter.git docs: note about plus character in query --- diff --git a/docs/api/index.md b/docs/api/index.md index b5b7ea42..75f80869 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -700,12 +700,12 @@ linkExactActiveClass?: string ### parseQuery -Custom implementation to parse a query. See its counterpart, [stringifyQuery](#stringifyquery). +Custom implementation to parse a query. Must decode query keys and values. See its counterpart, [stringifyQuery](#stringifyquery). **Signature:** ```typescript -parseQuery?: typeof originalParseQuery +parseQuery?: (searchQuery: string) => Record ``` #### Examples @@ -753,12 +753,17 @@ function scrollBehavior(to, from, savedPosition) { ### stringifyQuery -Custom implementation to stringify a query object. Should not prepend a leading `?`. [parseQuery](#parsequery) counterpart to handle query parsing. +Custom implementation to stringify a query object. Should not prepend a leading `?`. Should properly encode query keys and values. [parseQuery](#parsequery) counterpart to handle query parsing. **Signature:** ```typescript -stringifyQuery?: typeof originalStringifyQuery +stringifyQuery?: ( + query: Record< + string | number, + string | number | null | undefined | (string | number | null | undefined)[] + > +) => string ``` ## RouteRecordRaw diff --git a/docs/guide/migration/index.md b/docs/guide/migration/index.md index 51f97825..4e78d4d8 100644 --- a/docs/guide/migration/index.md +++ b/docs/guide/migration/index.md @@ -99,6 +99,7 @@ Given any [normalized route location](/api/#routelocationnormalized): - `hash` is now decoded, that way it can be copied over: `router.push({ hash: $route.hash })` and be used directly in [scrollBehavior](/api/#scrollbehavior)'s `el` option. - When using `push`, `resolve`, and `replace` and providing a `string` location or a `path` property in an object, **it must be encoded** (like in the previous version). On the other hand, `params`, `query` and `hash` must be provided in its unencoded version. - The slash character (`/`) is now properly decoded inside `params` while still producing an encoded version on the URL: `%2F`. +- The `+` character (`%2B` in its encoded form) no longer receives special treatment when found on the query section of the URL. It used to be encoded to deal with [legacy systems using `application/x-www-form-urlencoded`](https://url.spec.whatwg.org/#urlencoded-parsing). This can still be customized when providing custom [parsing and stringifying for `query`](/api/#stringifyquery) because they are responsible of encoding and decoding query params. **Reason**: This allows to easily copy existing properties of a location when calling `router.push()` and `router.resolve()`, and make the resulting route location consistent across browsers. `router.push()` is now idempotent, meaning that calling `router.push(route.fullPath)`, `router.push({ hash: route.hash })`, `router.push({ query: route.query })`, and `router.push({ params: route.params })` will not create extra encoding. @@ -203,7 +204,7 @@ try { Both `router.match`, and `router.resolve` have been merged together into `router.resolve` with a slightly different signature. [Refer to the API](/api/#resolve) for more details. -**Reason**: Uniting multiple methods that were use for the same purpose. +**Reason**: Uniting multiple methods that were used for the same purpose. ### Removal of `router.getMatchedComponents()`