summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-04 19:07:33 +0200
committerRaindropsSys <contact@minteck.org>2023-04-04 19:07:33 +0200
commitb9aca19cccf9fd85a05d2ae32846b5b4f25a4dc1 (patch)
tree1ecb5f1c27f159bb175ecded73d4235fcfb4b5ae /includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js
parent704e1c22efe6056b0fc2f59b2766f47e1c8d71cc (diff)
downloadpluralconnect-b9aca19cccf9fd85a05d2ae32846b5b4f25a4dc1.tar.gz
pluralconnect-b9aca19cccf9fd85a05d2ae32846b5b4f25a4dc1.tar.bz2
pluralconnect-b9aca19cccf9fd85a05d2ae32846b5b4f25a4dc1.zip
Added 147 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js')
-rw-r--r--includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js b/includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js
new file mode 100644
index 0000000..d769fdf
--- /dev/null
+++ b/includes/external/addressbook/node_modules/axios/lib/helpers/buildURL.js
@@ -0,0 +1,63 @@
+'use strict';
+
+import utils from '../utils.js';
+import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js';
+
+/**
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
+ * URI encoded counterparts
+ *
+ * @param {string} val The value to be encoded.
+ *
+ * @returns {string} The encoded value.
+ */
+function encode(val) {
+ return encodeURIComponent(val).
+ replace(/%3A/gi, ':').
+ replace(/%24/g, '$').
+ replace(/%2C/gi, ',').
+ replace(/%20/g, '+').
+ replace(/%5B/gi, '[').
+ replace(/%5D/gi, ']');
+}
+
+/**
+ * Build a URL by appending params to the end
+ *
+ * @param {string} url The base of the url (e.g., http://www.google.com)
+ * @param {object} [params] The params to be appended
+ * @param {?object} options
+ *
+ * @returns {string} The formatted url
+ */
+export default function buildURL(url, params, options) {
+ /*eslint no-param-reassign:0*/
+ if (!params) {
+ return url;
+ }
+
+ const _encode = options && options.encode || encode;
+
+ const serializeFn = options && options.serialize;
+
+ let serializedParams;
+
+ if (serializeFn) {
+ serializedParams = serializeFn(params, options);
+ } else {
+ serializedParams = utils.isURLSearchParams(params) ?
+ params.toString() :
+ new AxiosURLSearchParams(params, options).toString(_encode);
+ }
+
+ if (serializedParams) {
+ const hashmarkIndex = url.indexOf("#");
+
+ if (hashmarkIndex !== -1) {
+ url = url.slice(0, hashmarkIndex);
+ }
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
+ }
+
+ return url;
+}