Parcourir la source

remove "?" from user-search-query (#1103)

ChaosKid42 il y a 7 ans
Parent
commit
7a36acade5
3 fichiers modifiés avec 18 ajouts et 1 suppressions
  1. 2 0
      CHANGES.md
  2. 15 0
      docs/source/configuration.rst
  3. 1 1
      src/converse-rosterview.js

+ 2 - 0
CHANGES.md

@@ -41,6 +41,8 @@
   [statusMessageChanged](https://conversejs.org/docs/html/events.html#contactstatusmessagechanged)
   event and make the XMLHttpRequest yourself.
 - Removed  `xhr_user_search` in favor of only accepting `xhr_user_search_url` as configuration option.
+- `xhr_user_search_url` has to include the `?` character now in favor of more
+flexibility. See example in the documentation.
 - The data returned from the `xhr_user_search_url` must now include the user's
   `jid` instead of just an `id`.
 - New configuration settings [nickname](https://conversejs.org/docs/html/configurations.html#nickname)

+ 15 - 0
docs/source/configuration.rst

@@ -1587,3 +1587,18 @@ This is the URL to which an XHR GET request will be made to fetch user data from
 The query string will be included in the request with ``q`` as its key.
 
 The data returned must be a JSON encoded list of user JIDs.
+
+.. note::
+    converse.js will construct the XHR get URL by simply appending
+    ``q=<query string entered>`` to the URL given by ``xhr_user_search_url``.
+    It is therefore important that the necessary question mark (``?``) preceding the
+    URL's query component or necessary delimiters (``&``) are included. See valid
+    examples below.
+
+Examples:
+
+.. code-block:: javascript
+
+    xhr_user_search_url: 'https://some.url/some_path?',
+
+    xhr_user_search_url: 'https://some.url/some_path?api_key=somekey&',

+ 1 - 1
src/converse-rosterview.js

@@ -191,7 +191,7 @@
                         }
                     };
                     name_input.addEventListener('input', _.debounce(() => {
-                        xhr.open("GET", `${_converse.xhr_user_search_url}?q=${name_input.value}`, true);
+                        xhr.open("GET", `${_converse.xhr_user_search_url}q=${name_input.value}`, true);
                         xhr.send()
                     } , 300));
                     this.el.addEventListener('awesomplete-selectcomplete', (ev) => {