@atlaskit/editor-wikimarkup-transformer
Version:
Wiki markup transformer for JIRA and Confluence
28 lines (27 loc) • 1.01 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseAttrs = parseAttrs;
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
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 = (0, _toArray2.default)(_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;
}