Fixed filter.js generates incorrect URL when “Use full friendly URLs” is enabled

Painbaker

Well-known member
Affected version
2.3.7
When using filter.js on the public interface with AJAX filtering and the “Use full friendly URLs” option enabled, the generated request URL is incorrect. It misses a ? before the query string, which results in an invalid URL.

/forum-search/&_xfFilter[text]=test&_xfFilter[prefix]=0?_xfResponseType=json&_xfWithData=1&_xfRequestUri=/&_xfToken=1752795635,ed211239fc7c29d2bfdacd66aecf7ca10

When expected

/forum-search/?_xfFilter[text]=test&_xfFilter[prefix]=0?_xfResponseType=json&_xfWithData=1&_xfRequestUri=/&_xfToken=1752795635,ed211239fc7c29d2bfdacd66aecf7ca10


In filter.js, the URL is built by concatenating parameters using + '&' + params, regardless of whether the base AJAX URL contains a query string or not:


Code:
    _filterAjax (text, prefix)
        {
            //  
            if (!text.length)
            {
                this._clearAjaxRows()
                const matched = this._applyFilter(this._getSearchRows(), text, prefix)
                this._toggleNoResults(matched == 0)
            }
            else
            {
                const params = Object.entries({
                    text,
                    prefix: prefix ? 1 : 0,
                }).map(([key, value]) => `_xfFilter[${key}]=${encodeURIComponent(value)}`).join('&')

                const ajaxUrl = this.options.ajax + '&' + params // <--
                //
            }
        },
 
Last edited:
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.8).

Change log:
Fix filter JS query parameter concatenation
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom