web / useCleanQuery
Function: useCleanQuery() ​
useCleanQuery():
object
Defined in: composables/useCleanQuery/useCleanQuery.ts:13
Returns ​
buildQueryString ​
buildQueryString: (
query) =>string
Parameters ​
query ​
LocationQuery
The route query.
Returns ​
string
The query string including the leading ?, or an empty string if the query is empty.
Description ​
Serializes a query object like vue-router does: keys with multiple values are repeated and bare keys (?page, parsed as null) stay bare.
Example ​
buildQueryString({ tagIds: ['1', '2'], page: null }); // '?tagIds=1&tagIds=2&page'cleanFullPath ​
cleanFullPath: (
route) =>string
Parameters ​
route ​
Pick<RouteLocationNormalizedLoaded, "path" | "query" | "hash">
The route to clean.
Returns ​
string
The cleaned path, e.g. /shoes?page=2#top.
Description ​
Builds the path of a route with a cleaned query and the original hash.
Example ​
cleanFullPath(useRoute());cleanQuery ​
cleanQuery: (
query) =>LocationQuery
Parameters ​
query ​
LocationQuery
The route query.
Returns ​
LocationQuery
The filtered query, or the unchanged query if there is no whitelist.
Description ​
Removes all params that are not on the whitelist. Matching is case sensitive.
Example ​
cleanQuery({ page: '2', utm_source: 'x' }); // { page: '2' }Description ​
Keeps only query params that are part of the CloudFront cache key. The whitelist is delivered by the backend as the cacheKeyQueryParams setting. If it is missing, nothing is stripped.
Example ​
const { cleanQuery, cleanFullPath } = useCleanQuery();