UNPKG

ice.fo.utils

Version:

21 lines (17 loc) 472 B
/* eslint-disable guard-for-in */ import qs from 'qs'; import formatStringValue from './formatStringValue'; export default function convertToQueryObject({ text, data, parsePrefix = '#{', parseSuffix = '}', }) { try { const result = qs.parse(text); for (const k in result) { result[k] = formatStringValue(data, result[k], undefined, parsePrefix, parseSuffix); } return result; } catch (error) { console.error(error); return {}; } }