Home > widget-integration > FilterUrlHelper > getParamsHistory
FilterUrlHelper.getParamsHistory() method
Parses URL search parameters and extracts filter params, sort, and pagination.
Handles both shortened and full parameter formats by mapping short keys back to their long form using the longParamsMap from store.
Signature:
getParamsHistory(): {
paramList: Array<{
key: string;
values: string[];
}>;
sort: string | null;
pagination: {
page: string | null;
};
};
Returns:
{ paramList: Array<{ key: string; values: string[]; }>; sort: string | null; pagination: { page: string | null; }; }
Object containing: - paramList: Array of filter parameters, each with key (long form) and values array - sort: Current sort parameter string or null if not present - pagination: Object with page property (string or null)
Remarks
This method handles multiple edge cases for robust URL parsing: - Decodes URL-encoded values and replaces '+' with spaces - Splits multi-value parameters by configured separator (default ',') - Maps shortened parameter keys back to full keys using longParamsMap - Handles both encoded and non-encoded separators in URLs - Preserves parameter order for consistent behavior - Only extracts parameters with the FILTER_KEY_PREFIX ('pf_')
Example 1
Parse current URL parameters:
const { paramList, sort, pagination } = this.urlHelper.getParamsHistory();
// paramList = [{ key: 'pf_brand', values: ['Nike', 'Adidas'] }]
// sort = 'price-asc'
// pagination = { page: '2' }
Example 2
Extend to add custom parameter parsing:
window.boostWidgetIntegration.extend('FilterUrlHelper', (FilterUrlHelper) => {
return class extends FilterUrlHelper {
getParamsHistory() {
const result = super.getParamsHistory();
// Add custom parameter extraction
const customParam = new URLSearchParams(window.location.search).get('custom');
return { ...result, customParam };
}
};
});