aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/nfvo-utils/objectPropsToUrlString.js
blob: 6c18bb61119bcfaea8bc6b15606dd5956b0b49c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export default function objectPropsToUrlString(data) {
    let str = '';
    Object.keys(data).map(key => {
        if (typeof data[key] === 'object') {
            let obj = data[key];
            let arr = [];

            Object.keys(obj).map(prop => {
                if (obj[prop]) {
                    arr.push(encodeURIComponent(prop));
                }
            });
            if (arr.length) {
                str += `&${encodeURIComponent(key)}=${arr.join(',')}`;
            }
        } else if (data[key]) {
            str += `&${encodeURIComponent(key)}=${encodeURIComponent(
                data[key]
            )}`;
        }
    });
    return str;
}