Skip to main content

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

NameTypeDescription
searchstring or RegExpSearch 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

NameTypeOptionalDescription
textstringA text to populate.
paramsany✔️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

NameTypeOptionalDescriptionDefault
textstringA search url string.
paramsURLSearchParams | SearchParams✔️Params that should be added to the text.
optionsPopulateParamsOptions✔️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.