ParamsHelper
The ParamsHelper offers functionality to work with search params.
import { ParamsHelper } from '@archibald/core';
filterSearch
This method filters the url params to only allow valid ones. This method uses custom/validUrlParams property that can be set with ConfigManager. If nothing is configured just return all params.
import { ParamsHelper } from '@archibald/core';
const search = ParamsHelper.filterSearch(PARAMETERS);
Parameters
| Name | Type | Description |
|---|---|---|
| search | string or RegExp | Search string that should be used as a filter. |
populate
This method populates a text with parameters.
import { ParamsHelper } from '@archibald/core';
const text = ParamsHelper.populate(PARAMETERS);
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
| text | string | A text to populate. | |
| params | any | ✔️ | Params that should be added to the text. |
create
This method adds search parameters to an url, and returns url.
import { ParamsHelper } from '@archibald/core';
const url = ParamsHelper.create(PARAMETERS);
Parameters
| Name | Type | Optional | Description | Default |
|---|---|---|---|---|
| text | string | A search url string. | ||
| params | URLSearchParams | SearchParams | ✔️ | Params that should be added to the text. | |
| options | PopulateParamsOptions | ✔️ | Options to control behaviour of this method. filter (default: true) if you want to have only one unique param key and allowMoreEqual (default: true) you use in case value of the param is array and you either want to have param key appended for each value or have one param key and all values assigned to it as strings joined with comma (@deprecated v4), sort (default: true) is commanding if the searchParams array is sorted before returned, to help with consistent caching, allowEmptyString (default: false) is a flag to allow empty string. |