Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit d5bd874

Browse files
committed
added some checking and casting to make split calls reliable
1 parent fd04084 commit d5bd874

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/manifestTools/validationRules/w3cManifestSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function (manifestContent, callback) {
4040
});
4141
}
4242

43-
var member = err.dataPath.split('/').pop();
43+
var member = err.dataPath && typeof err.dataPath === "string" && err.dataPath.split('/').pop();
4444
if (err.code !== tv4.errorCodes.UNKNOWN_PROPERTY || (member && member.indexOf('_') < 0)) {
4545
validationResults.push({
4646
'description': message,

lib/processTools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var node_modules = 'node_modules';
1414

1515
function writeOutput(text, bufferedOutput, source, title) {
1616

17-
var lines = (title + bufferedOutput + text).split(/\r?\n/);
17+
var lines = ("" + title + bufferedOutput + text).split(/\r?\n/);
1818
bufferedOutput = lines.pop();
1919

2020
lines.forEach(function (line) {

lib/validations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ function isExpectedValidationError(errorResult) {
4242
}
4343

4444
function isExpectedCase(errorResult, w3cManifestInfo) {
45+
if (!errorResult.member) {
46+
return true;
47+
}
48+
4549
const errorParams = errorResult.member.split('/').slice(1) //example: /icons/0/purpose -> ['icons', '0', 'purpose']
4650
const isIconsPurpose = errorResult.member.includes("icons") && errorResult.member.includes("purpose");
4751
const isShortcuts = errorResult.member.includes("shortcuts");
@@ -56,9 +60,10 @@ function isExpectedCase(errorResult, w3cManifestInfo) {
5660

5761
return w3cManifestInfo.content.icons
5862
&& w3cManifestInfo.content.icons[index]
63+
&& w3cManifestInfo.content.icons[index].purpose
5964
&& w3cManifestInfo.content.icons[index].purpose.split(" ").filter(entry => {
6065
return (entry === "any" || entry === "maskable" || entry === "monochrome");
61-
}).length > 0
66+
}).length > 0;
6267
}
6368

6469
return false;

0 commit comments

Comments
 (0)