From 64b432916af9c9218ab3f3eca614e26c542142ae Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期二, 07 十一月 2023 15:47:13 +0800 Subject: [PATCH] bug --- minipro_standard/uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js | 138 +++++++++++++++++++++++----------------------- 1 files changed, 69 insertions(+), 69 deletions(-) diff --git a/minipro_standard/uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js b/minipro_standard/uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js index 919b5e6..472ad6a 100644 --- a/minipro_standard/uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js +++ b/minipro_standard/uni_modules/uview-ui/libs/luch-request/helpers/buildURL.js @@ -1,69 +1,69 @@ -'use strict' - -import * as utils from '../utils' - -function encode(val) { - return encodeURIComponent(val) - .replace(/%40/gi, '@') - .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 - * @returns {string} The formatted url - */ -export default function buildURL(url, params) { - /* eslint no-param-reassign:0 */ - if (!params) { - return url - } - - let serializedParams - if (utils.isURLSearchParams(params)) { - serializedParams = params.toString() - } else { - const parts = [] - - utils.forEach(params, (val, key) => { - if (val === null || typeof val === 'undefined') { - return - } - - if (utils.isArray(val)) { - key = `${key}[]` - } else { - val = [val] - } - - utils.forEach(val, (v) => { - if (utils.isDate(v)) { - v = v.toISOString() - } else if (utils.isObject(v)) { - v = JSON.stringify(v) - } - parts.push(`${encode(key)}=${encode(v)}`) - }) - }) - - serializedParams = parts.join('&') - } - - if (serializedParams) { - const hashmarkIndex = url.indexOf('#') - if (hashmarkIndex !== -1) { - url = url.slice(0, hashmarkIndex) - } - - url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams - } - - return url -} +'use strict' + +import * as utils from '../utils' + +function encode(val) { + return encodeURIComponent(val) + .replace(/%40/gi, '@') + .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 + * @returns {string} The formatted url + */ +export default function buildURL(url, params) { + /* eslint no-param-reassign:0 */ + if (!params) { + return url + } + + let serializedParams + if (utils.isURLSearchParams(params)) { + serializedParams = params.toString() + } else { + const parts = [] + + utils.forEach(params, (val, key) => { + if (val === null || typeof val === 'undefined') { + return + } + + if (utils.isArray(val)) { + key = `${key}[]` + } else { + val = [val] + } + + utils.forEach(val, (v) => { + if (utils.isDate(v)) { + v = v.toISOString() + } else if (utils.isObject(v)) { + v = JSON.stringify(v) + } + parts.push(`${encode(key)}=${encode(v)}`) + }) + }) + + serializedParams = parts.join('&') + } + + if (serializedParams) { + const hashmarkIndex = url.indexOf('#') + if (hashmarkIndex !== -1) { + url = url.slice(0, hashmarkIndex) + } + + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams + } + + return url +} -- Gitblit v1.9.3