UNPKG

@atlaskit/editor-wikimarkup-transformer

Version:

Wiki markup transformer for JIRA and Confluence

21 lines 774 B
import _toArray from "@babel/runtime/helpers/toArray"; export function parseAttrs(str) { var sep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '|'; var output = {}; if (!str) { return output; } var attributesStr = str.split(sep); attributesStr.forEach(function (attributeStr) { // eslint-disable-next-line @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed) var _attributeStr$split = attributeStr.split('='), _attributeStr$split2 = _toArray(_attributeStr$split), key = _attributeStr$split2[0], value = _attributeStr$split2.slice(1); // take only first value of the same keys if (!output[key]) { output[key] = value.join('='); } }); return output; }