/**
 * 对象转query字符串
 * @param obj
 */
export function obj2query(obj: string[][] | Record<string, string> | string | URLSearchParams): string {
    return new URLSearchParams(obj).toString();
    // if(!obj) {
    // 	return '';
    // }
    // const arr: string[] = [];
    // for(const key in obj) {
    // 	arr.push(key + (key ? '=' : '') + obj[key]);
    // }
    // return arr.join('&');
}

export function urlJoin(url: string, query: any) {
    if (query) {
        url += url.indexOf('?') < 0 ? '?' : '';
        url += url[url.length - 1] === '?' ? '' : '&';
        return url + query;
    } else {
        return url;
    }
}
