]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: note about plus character in query
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 7 Oct 2020 14:46:29 +0000 (16:46 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 7 Oct 2020 14:46:29 +0000 (16:46 +0200)
docs/api/index.md
docs/guide/migration/index.md

index b5b7ea421ddb7d579faea4626d96b37106e6eeae..75f808699b31261ee6f56dca4626a869396b2bdf 100644 (file)
@@ -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<string, (string | null)[] | string | null>
 ```
 
 #### 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
index 51f9782554dea1acf022be30131aa76634a6bd97..4e78d4d8141c8bfeb40b9b480dd13664aed0dac0 100644 (file)
@@ -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()`