diff options
Diffstat (limited to 'openecomp-ui/src/nfvo-utils/objectPropsToUrlString.js')
-rw-r--r-- | openecomp-ui/src/nfvo-utils/objectPropsToUrlString.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/openecomp-ui/src/nfvo-utils/objectPropsToUrlString.js b/openecomp-ui/src/nfvo-utils/objectPropsToUrlString.js new file mode 100644 index 0000000000..6c18bb6111 --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/objectPropsToUrlString.js @@ -0,0 +1,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; +} |