-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
core: remove last debugString references #5856
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,21 +37,21 @@ const ALLOWED_ORIENTATION_VALUES = [ | |
*/ | ||
function parseString(raw, trim) { | ||
let value; | ||
let debugString; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like we want the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
sounds like you're upset with our decision to use I'm not 100% sure what you're advocating for, is it for this PR to just remove the TODO and fix the tests then since we don't want to pursue it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
haha, well, In this case the only indication that there was an issue is the existence of the string. I meant just for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looked and within manifest-parser, i'd say that, semantically, all these properties are really So i'd be in favor of changing the manifestparser explanation->warning for all items and errorMesssage on the toplevel. and also tweaking manifest-values.js to use these terms as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brendankenny are you on board with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes, sounds good to me
lol yes, that's terrible |
||
let explanation; | ||
|
||
if (typeof raw === 'string') { | ||
value = trim ? raw.trim() : raw; | ||
} else { | ||
if (raw !== undefined) { | ||
debugString = 'ERROR: expected a string.'; | ||
explanation = 'ERROR: expected a string.'; | ||
} | ||
value = undefined; | ||
} | ||
|
||
return { | ||
raw, | ||
value, | ||
debugString, | ||
explanation, | ||
}; | ||
} | ||
|
||
|
@@ -70,7 +70,7 @@ function parseColor(raw) { | |
const validatedColor = validateColor(color.raw); | ||
if (!validatedColor) { | ||
color.value = undefined; | ||
color.debugString = 'ERROR: color parsing failed.'; | ||
color.explanation = 'ERROR: color parsing failed.'; | ||
} | ||
|
||
return color; | ||
|
@@ -117,7 +117,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { | |
return { | ||
raw, | ||
value: documentUrl, | ||
debugString: 'ERROR: start_url string empty', | ||
explanation: 'ERROR: start_url string empty', | ||
}; | ||
} | ||
const parsedAsString = parseString(raw); | ||
|
@@ -135,7 +135,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { | |
return { | ||
raw, | ||
value: documentUrl, | ||
debugString: 'ERROR: invalid start_url relative to ${manifestUrl}', | ||
explanation: 'ERROR: invalid start_url relative to ${manifestUrl}', | ||
}; | ||
} | ||
|
||
|
@@ -144,7 +144,7 @@ function parseStartUrl(jsonInput, manifestUrl, documentUrl) { | |
return { | ||
raw, | ||
value: documentUrl, | ||
debugString: 'ERROR: start_url must be same-origin as document', | ||
explanation: 'ERROR: start_url must be same-origin as document', | ||
}; | ||
} | ||
|
||
|
@@ -165,7 +165,7 @@ function parseDisplay(jsonInput) { | |
return { | ||
raw: jsonInput, | ||
value: DEFAULT_DISPLAY_MODE, | ||
debugString: parsedString.debugString, | ||
explanation: parsedString.explanation, | ||
}; | ||
} | ||
|
||
|
@@ -174,15 +174,15 @@ function parseDisplay(jsonInput) { | |
return { | ||
raw: jsonInput, | ||
value: DEFAULT_DISPLAY_MODE, | ||
debugString: 'ERROR: \'display\' has invalid value ' + displayValue + | ||
explanation: 'ERROR: \'display\' has invalid value ' + displayValue + | ||
`. will fall back to ${DEFAULT_DISPLAY_MODE}.`, | ||
}; | ||
} | ||
|
||
return { | ||
raw: jsonInput, | ||
value: displayValue, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -195,7 +195,7 @@ function parseOrientation(jsonInput) { | |
if (orientation.value && | ||
!ALLOWED_ORIENTATION_VALUES.includes(orientation.value.toLowerCase())) { | ||
orientation.value = undefined; | ||
orientation.debugString = 'ERROR: \'orientation\' has an invalid value, will be ignored.'; | ||
orientation.explanation = 'ERROR: \'orientation\' has an invalid value, will be ignored.'; | ||
} | ||
|
||
return orientation; | ||
|
@@ -223,13 +223,13 @@ function parseIcon(raw, manifestUrl) { | |
raw: raw.density, | ||
value: 1, | ||
/** @type {string|undefined} */ | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
if (density.raw !== undefined) { | ||
density.value = parseFloat(density.raw); | ||
if (isNaN(density.value) || !isFinite(density.value) || density.value <= 0) { | ||
density.value = 1; | ||
density.debugString = 'ERROR: icon density cannot be NaN, +∞, or less than or equal to +0.'; | ||
density.explanation = 'ERROR: icon density cannot be NaN, +∞, or less than or equal to +0.'; | ||
} | ||
} | ||
|
||
|
@@ -242,7 +242,7 @@ function parseIcon(raw, manifestUrl) { | |
sizes = { | ||
raw: raw.sizes, | ||
value: set.size > 0 ? Array.from(set) : undefined, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} else { | ||
sizes = {...parsedSizes, value: undefined}; | ||
|
@@ -256,7 +256,7 @@ function parseIcon(raw, manifestUrl) { | |
density, | ||
sizes, | ||
}, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -272,7 +272,7 @@ function parseIcons(jsonInput, manifestUrl) { | |
raw, | ||
/** @type {Array<ReturnType<typeof parseIcon>>} */ | ||
value: [], | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -281,7 +281,7 @@ function parseIcons(jsonInput, manifestUrl) { | |
raw, | ||
/** @type {Array<ReturnType<typeof parseIcon>>} */ | ||
value: [], | ||
debugString: 'ERROR: \'icons\' expected to be an array but is not.', | ||
explanation: 'ERROR: \'icons\' expected to be an array but is not.', | ||
}; | ||
} | ||
|
||
|
@@ -298,7 +298,7 @@ function parseIcons(jsonInput, manifestUrl) { | |
return { | ||
raw, | ||
value, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -317,7 +317,7 @@ function parseApplication(raw) { | |
appUrl.value = new URL(appUrl.value).href; | ||
} catch (e) { | ||
appUrl.value = undefined; | ||
appUrl.debugString = 'ERROR: invalid application URL ${raw.url}'; | ||
appUrl.explanation = 'ERROR: invalid application URL ${raw.url}'; | ||
} | ||
} | ||
|
||
|
@@ -328,7 +328,7 @@ function parseApplication(raw) { | |
id, | ||
url: appUrl, | ||
}, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -342,15 +342,15 @@ function parseRelatedApplications(jsonInput) { | |
return { | ||
raw, | ||
value: undefined, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
if (!Array.isArray(raw)) { | ||
return { | ||
raw, | ||
value: undefined, | ||
debugString: 'ERROR: \'related_applications\' expected to be an array but is not.', | ||
explanation: 'ERROR: \'related_applications\' expected to be an array but is not.', | ||
}; | ||
} | ||
|
||
|
@@ -364,7 +364,7 @@ function parseRelatedApplications(jsonInput) { | |
return { | ||
raw, | ||
value, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
@@ -374,21 +374,21 @@ function parseRelatedApplications(jsonInput) { | |
function parsePreferRelatedApplications(jsonInput) { | ||
const raw = jsonInput.prefer_related_applications; | ||
let value; | ||
let debugString; | ||
let explanation; | ||
|
||
if (typeof raw === 'boolean') { | ||
value = raw; | ||
} else { | ||
if (raw !== undefined) { | ||
debugString = 'ERROR: \'prefer_related_applications\' expected to be a boolean.'; | ||
explanation = 'ERROR: \'prefer_related_applications\' expected to be a boolean.'; | ||
} | ||
value = undefined; | ||
} | ||
|
||
return { | ||
raw, | ||
value, | ||
debugString, | ||
explanation, | ||
}; | ||
} | ||
|
||
|
@@ -425,7 +425,7 @@ function parse(string, manifestUrl, documentUrl) { | |
return { | ||
raw: string, | ||
value: undefined, | ||
debugString: 'ERROR: file isn\'t valid JSON: ' + e, | ||
explanation: 'ERROR: file isn\'t valid JSON: ' + e, | ||
}; | ||
} | ||
|
||
|
@@ -447,7 +447,7 @@ function parse(string, manifestUrl, documentUrl) { | |
return { | ||
raw: string, | ||
value: manifest, | ||
debugString: undefined, | ||
explanation: undefined, | ||
}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning
/errorMessage
?