export default class URIUtil {
    static appendParams(uri, params) {
        if (uri && typeof params === 'object') {
            let paramsStr = Object.entries(params).map(item => {
                let value = item[1]
                return item[0] + '=' + (value ? encodeURIComponent(value) : '')
            }).join("&")
            if (paramsStr && paramsStr.length > 0) {
                uri += (uri.search(/\?/) < 0 ? '?' : '&') + paramsStr
            }
        }
        return uri
    }
    static parseParams(uri) {
        var parse = uri.substring(uri.indexOf("?") + 1),
            params = parse.split("&"),
            len = params.length,
            item = [],
            param = {};

        for (var i = 0; i < len; i++) {
            item = params[i].split("=");
            param[item[0]] = item[1];
        }

        return param;
    }
}