Skip to content

Commit

Permalink
Update GH pages using commit aef5282
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 26, 2023
1 parent 20d8b47 commit 8402494
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion exif-reader.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion exif-reader.js.map

Large diffs are not rendered by default.

44 changes: 36 additions & 8 deletions src/xmp-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,16 @@ function parseNodeAttributesAsTags(attributes) {
const tags = {};

for (const name in attributes) {
if (isTagAttribute(name)) {
tags[getLocalName(name)] = {
value: attributes[name],
attributes: {},
description: getDescription(attributes[name], name)
};
try {
if (isTagAttribute(name)) {
tags[getLocalName(name)] = {
value: attributes[name],
attributes: {},
description: getDescription(attributes[name], name)
};
}
} catch (error) {
// Keep going and try to parse the rest of the tags.
}
}

Expand Down Expand Up @@ -321,15 +325,25 @@ function parseNodeChildrenAsTags(children) {
const tags = {};

for (const name in children) {
if (!isNamespaceDefinition(name)) {
tags[getLocalName(name)] = parseNodeAsTag(children[name], name);
try {
if (!isNamespaceDefinition(name)) {
tags[getLocalName(name)] = parseNodeAsTag(children[name], name);
}
} catch (error) {
// Keep going and try to parse the rest of the tags.
}
}

return tags;
}

function parseNodeAsTag(node, name) {
if (isDuplicateTag(node)) {
return parseNodeAsDuplicateTag(node, name);
}
if (isEmptyResourceTag(node)) {
return {value: '', attributes: {}, description: ''};
}
if (hasNestedSimpleRdfDescription(node)) {
return parseNodeAsSimpleRdfDescription(node, name);
}
Expand All @@ -345,6 +359,20 @@ function parseNodeAsTag(node, name) {
return parseNodeAsSimpleValue(node, name);
}

function isEmptyResourceTag(node) {
return (node.attributes['rdf:parseType'] === 'Resource')
&& (typeof node.value === 'string')
&& (node.value.trim() === '');
}

function isDuplicateTag(node) {
return Array.isArray(node);
}

function parseNodeAsDuplicateTag(node, name) {
return parseNodeAsSimpleValue(node[node.length - 1], name);
}

function hasNestedSimpleRdfDescription(node) {
return ((node.attributes['rdf:parseType'] === 'Resource') && (node.value['rdf:value'] !== undefined))
|| ((node.value['rdf:Description'] !== undefined) && (node.value['rdf:Description'].value['rdf:value'] !== undefined));
Expand Down

0 comments on commit 8402494

Please sign in to comment.