Skip to content

Commit

Permalink
softwareRequirements: Ignore empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Oct 25, 2024
1 parent f54eb88 commit c9f6aba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cypress/integration/special_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ describe('Software requirements', function() {
});
});

it('can be exported despite a trailing newline', function() {
cy.get('#name').type('My Test Software');

cy.get('#softwareRequirements').type('https://github.com/GNOME/libxml2\n');

cy.get('#generateCodemetaV2').click();

cy.get('#errorMessage').should('have.text', '');
cy.get('#codemetaText').then((elem) => JSON.parse(elem.text()))
.should('deep.equal', {
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"type": "SoftwareSourceCode",
"name": "My Test Software",
"softwareRequirements": "https://github.com/GNOME/libxml2",
});
});

it('can be imported from a single URI', function() {
cy.get('#codemetaText').then((elem) =>
elem.text(JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion js/codemeta_generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async function buildExpandedDocWithAllContexts() {
const deserializer = item[3];
let value = getIfSet('#' + id);
if (value !== undefined) {
value = value.split(separator).map(trimSpaces);
value = value.split(separator).map(trimSpaces).filter((item) => item != "");
if (serializer !== undefined) {
value = value.map((item) => serializer(id, item));
}
Expand Down

0 comments on commit c9f6aba

Please sign in to comment.