Skip to content

Commit f7861e8

Browse files
committed
softwareRequirements: Ignore empty lines
1 parent 020eb89 commit f7861e8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

cypress/integration/special_fields.js

+17
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ describe('Software requirements', function() {
146146
});
147147
});
148148

149+
it('can be exported despite a trailing newline', function() {
150+
cy.get('#name').type('My Test Software');
151+
152+
cy.get('#softwareRequirements').type('https://github.com/GNOME/libxml2\n');
153+
154+
cy.get('#generateCodemetaV2').click();
155+
156+
cy.get('#errorMessage').should('have.text', '');
157+
cy.get('#codemetaText').then((elem) => JSON.parse(elem.text()))
158+
.should('deep.equal', {
159+
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
160+
"type": "SoftwareSourceCode",
161+
"name": "My Test Software",
162+
"softwareRequirements": "https://github.com/GNOME/libxml2",
163+
});
164+
});
165+
149166
it('can be imported from a single URI', function() {
150167
cy.get('#codemetaText').then((elem) =>
151168
elem.text(JSON.stringify({

js/codemeta_generation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ async function buildExpandedDocWithAllContexts() {
263263
const deserializer = item[3];
264264
let value = getIfSet('#' + id);
265265
if (value !== undefined) {
266-
value = value.split(separator).map(trimSpaces);
266+
value = value.split(separator).map(trimSpaces).filter((item) => item != "");
267267
if (serializer !== undefined) {
268268
value = value.map((item) => serializer(id, item));
269269
}

0 commit comments

Comments
 (0)