Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for multiple TYPE parameters #388

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/ical/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,22 @@ ICAL.parse = (function() {
value = parser._rfc6868Escape(value);
if (multiValue) {
var delimiter = mvdelim || multiValue;
result[lcname] = parser._parseMultiValue(value, delimiter, type, [], null, designSet);
value = parser._parseMultiValue(value, delimiter, type, [], null, designSet);
} else {
result[lcname] = parser._parseValue(value, type, designSet);
value = parser._parseValue(value, type, designSet);
}

if (multiValue && (lcname in result)) {
if (Array.isArray(result[lcname])) {
result[lcname].push(value);
} else {
result[lcname] = [
result[lcname],
value
];
}
} else {
result[lcname] = value;
}
}
return [result, value, valuePos];
Expand Down
24 changes: 24 additions & 0 deletions test/parse_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,30 @@ suite('parserv2', function() {
expected
);
});

test('with multiple vCard TYPE parameters', function() {
var input = ';TYPE=work;TYPE=voice';
var expected = {
'type': ['work', 'voice']
};

assert.deepEqual(
subject._parseParameters(input, 0, ICAL.design.components.vcard)[0],
expected
);
});

test('with multiple iCalendar MEMBER parameters', function() {
var input = ';MEMBER="urn:one","urn:two";MEMBER="urn:three"';
var expected = {
'member': ['urn:one', 'urn:two', 'urn:three']
};

assert.deepEqual(
subject._parseParameters(input, 0, ICAL.design.components.vevent)[0],
expected
);
});
});

test('#_parseMultiValue', function() {
Expand Down