mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 05:19:51 +00:00
feat: git login
This commit is contained in:
@@ -53,6 +53,36 @@ export const Obj2Query = (obj: Record<string, string | number>) => {
|
||||
return queryParams.toString();
|
||||
};
|
||||
|
||||
export const parseQueryString = (str: string) => {
|
||||
const queryObject: Record<string, any> = {};
|
||||
|
||||
const splitStr = str.split('?');
|
||||
|
||||
str = splitStr[1] || splitStr[0];
|
||||
|
||||
// 将字符串按照 '&' 分割成键值对数组
|
||||
const keyValuePairs = str.split('&');
|
||||
|
||||
// 遍历键值对数组,将每个键值对解析为对象的属性和值
|
||||
keyValuePairs.forEach(function (keyValuePair) {
|
||||
const pair = keyValuePair.split('=');
|
||||
const key = decodeURIComponent(pair[0]);
|
||||
const value = decodeURIComponent(pair[1] || '');
|
||||
|
||||
// 如果对象中已经存在该属性,则将值转换为数组
|
||||
if (queryObject.hasOwnProperty(key)) {
|
||||
if (!Array.isArray(queryObject[key])) {
|
||||
queryObject[key] = [queryObject[key]];
|
||||
}
|
||||
queryObject[key].push(value);
|
||||
} else {
|
||||
queryObject[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return queryObject;
|
||||
};
|
||||
|
||||
/**
|
||||
* 格式化时间成聊天格式
|
||||
*/
|
||||
|
Reference in New Issue
Block a user